6

I'm using Solr auto-suggest with the SXA search box, it's working perfect but with two issues, first it brings suggestion for all data in the site without any limitation, I want to limit to a search scope or a specific template type, second I want it to bring specific version(language), in English website it brings all data with all languages which is wrong.

1
  • Please create a separate question for your second topic regarding language so your question is unique and not ambiguos for other visitors Commented Sep 10, 2018 at 20:25

2 Answers 2

4

There are a few ways you can limit the scope for the Search components. First have a look here at the SXA documentation.

Start under Settings > Scopes. Here you can define the search query and rules for boosting.

enter image description here

On the page you can specify the scope:

enter image description here

On the Search Results component you can also configure the scope:

enter image description here

1
  • I'm using a scope but it doesn't limit the auto suggest, it limits the search results, I need to filter the auto suggest results, there is a something called context filtering and I use it ti filter by language, but still it's not working. Commented Sep 12, 2018 at 7:15
3

We recently explored ContextFiltering in Solr, but we used a custom asp.net mvc controller rendering to do the filtering logic based on template.

We have used the documentation on Sitecore Docs AutoSuggest.

You need to edit the SolrConfig.xml and add the below sections to enable SOLR AutoSuggest Feature

<searchComponent name="suggest" class="solr.SuggestComponent">
  <lst name="suggester">
    <str name="name">CustomSuggester</str>
    <str name="lookupImpl">AnalyzingInfixLookupFactory</str>
    <str name="dictionaryImpl">DocumentDictionaryFactory</str>
    <str name="field">sxacontent_txm</str>
    <str name="contextField">_template</str> 
    <str name="suggestAnalyzerFieldType">text_general</str>
    <str name="buildOnStartup">false</str>
  </lst>
</searchComponent>

In above Section , contextField is the field we can use for template based filter. We can also pass Language. You would also need to pass the appropriate value in ContentSearchRepository for Template and Language Fields

I have blogged about the same here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.