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.
2 Answers
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.
On the page you can specify the scope:
On the Search Results component you can also configure the scope:
-
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
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