I have a list of product pages for one of my Australia sites where the content is in 2 language versions:
- EN
- en-AU
I have a search suggestion box where I am trying to populate few of the title fields through a computed field named as autosuggestiontitle_sm
Here's my suggester component defined in solrconfig.xml:
<searchComponent name="suggest" class="solr.SuggestComponent">
<lst name="suggester">
<str name="name">mySuggester</str>
<str name="lookupImpl">BlendedInfixLookupFactory</str>
<str name="dictionaryImpl">DocumentDictionaryFactory</str>
<str name="field">**autosuggestiontitle_sm**</str>
<str name="contextField">**_contextLanguage**</str>
<str name="suggestAnalyzerFieldType">**text_suggester**</str>
<str name="buildOnStartup">true</str>
</lst>
</searchComponent>
<requestHandler name="/suggest" class="solr.SearchHandler" startup="lazy" >
<lst name="defaults">
<str name="suggest">true</str>
<str name="suggest.dictionary">mySuggester</str>
<str name="suggest.count">10</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>
Since my suggestAnalyzerFieldType is a custom field, I have included the below entries in managed-schema file as below:
<fieldType **name="text_suggester"** class="solr.TextField" positionIncrementGap="100" multiValued="true">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" words="stopwords.txt" ignoreCase="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" words="stopwords.txt" ignoreCase="true"/>
<filter class="solr.SynonymFilterFactory" expand="true" ignoreCase="true" synonyms="synonyms.txt"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
And have added the 2 custom fields by defining the type as text_suggester:
<field name="autosuggestiontitle_sm" type="text_suggester" multiValued="true" indexed="true" stored="true"/>
<field name="_contextLanguage" type="text_suggester" multiValued="false" indexed="true" stored="true"/>
Since _language is a string type I have defined a custom field name as _contextLanguage of type text_suggester so added the below **copyField **entry:
Then, I did restart my solr server and re-indexed my custom index pertaining to my website context. Now my search term is "fit".
Scenario 1 Query: https://localhost:8983/solr/custom_master_index/suggest?q=fit
Result is as expected which is picking 7 results where "fit" terms appears in title text from both EN and en-AU versions
Scenario 2 Query: https://localhost:8983/solr/custom_master_index/suggest?q=fit&suggest=true&suggest.cfq=en
Result is as expected which is picking 2 results where "fit" terms appears in title text from EN content.
But the issue is that when I query with en-AU which is my current context language of my Australia site, the result is either 0 or at time I see the EN results.
(Issue)Scenario 3 Query: https://localhost:8983/solr/custom_master_index/suggest?q=fit&suggest=true&suggest.cfq=en-AU
Note: I have tried to run the query with different values like suggest.cfq=en-au, suggest.cfq=au (nothing helped)
Can someone help me understand what is being missed so that en-AU contextField is not querying the right values.
Thanks in advance!