Ammar Ammar - 4 months ago 32
Java Question

Solr Suggester - case insensitive

I am trying to work on an autocomplete feature on Solr and the way I found how to do it, is to use Solr Suggester. However, it does not work as expected. If someone invokes

http://localhost:8983/solr/techproducts/suggest?suggest=true&suggest.build=true&suggest.dictionary=mySuggester&wt=json&suggest.q=a
while the index has a field that starts with
Apple
it will not come out. I have request with
suggest.q=A
(with an upper case).

Is there a way to make Solr Suggester case-insensitive?

Here are my configurations:

<searchComponent name="suggest" class="solr.SuggestComponent">
<lst name="suggester">
<str name="name">mySuggester</str>
<str name="lookupImpl">FuzzyLookupFactory</str>
<str name="dictionaryImpl">DocumentDictionaryFactory</str>
<str name="field">autocomp</str>
<str name="weightField">price</str>
<str name="suggestAnalyzerFieldType">string</str>
</lst>
</searchComponent>


Here are relevent parts of the schema:

<fieldType class="solr.TextField" name="textSuggest" positionIncrementGap="100">
<analyzer>
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StandardFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>

<field name="autocomp" type="textSuggest" indexed="true" stored="true" multiValued="true"/>

<copyField source="title" dest="autocomp"/>


Thanks

Answer

I found out that the issue is with this part of searchComponent configurations:

<str name="suggestAnalyzerFieldType">string</str>

You have to put the field you are using for analyzing the text. In my case it was:

<str name="suggestAnalyzerFieldType">text_general</str>