Make SOLR spellcheck case insensitive, but return to original case

I am implementing a search service with SOLR 4.10 and would like to offer search suggestions based on the already specified term. A pretty standard feature for today's search applications ...

What I want is that SOLR searches for a case insensitive case, but returns a source string that seems impossible ... look for: abc return: AbCdEfG

when I use "LowerCaseFilterFactory", the search is case insensitive, but the returned sentences are all lower. When I delete it, the returned sentences are original, but the search is not case sensitive .... = /

I added this request handler and searched in my solrconfig.xml file:

<requestHandler name="/suggest" class="org.apache.solr.handler.component.SearchHandler"> <lst name="defaults"> <str name="echoParams">none</str> <str name="wt">json</str> <str name="indent">false</str> <str name="spellcheck">true</str> <str name="spellcheck.dictionary">_all</str> <str name="spellcheck.onlyMorePopular">false</str> <str name="spellcheck.count">20</str> <str name="spellcheck.collate">false</str> </lst> <arr name="components"> <str>suggest</str> </arr> </requestHandler> <searchComponent name="suggest" class="solr.SpellCheckComponent" > <lst name="spellchecker"> <str name="name">_all</str> <str name="classname">org.apache.solr.spelling.suggest.Suggester</str> <str name="lookupImpl">org.apache.solr.spelling.suggest.fst.FSTLookupFactory</str> <str name="field">_all</str> <float name="threshold">0.</float> <str name="buildOnCommit">true</str> </lst> 

I added this to my schema.xml

 <fields> <field name="_all" type="string" indexed="true" stored="false" multiValued="true" omitNorms="true" /> </fields> <types> <fieldType name="string" class="solr.TextField"> <analyzer> <tokenizer class="solr.KeywordTokenizerFactory" /> <filter class="solr.LowerCaseFilterFactory" /> <filter class="solr.TrimFilterFactory" /> </analyzer> </fieldType> </types> 
+6
source share
1 answer

I think that if you set the saved attribute to true in the fields that you want to return the original value and reindex, it will solve your problem.

If the index attribute is true in the field, Solr only stores the tokens that it receives from the analysis of the document in its index. Therefore, your Solr index contains only case-insensitive tokens taken from your documents. If the store is also set to true, then it stores the original term somewhere in the index that it creates so that it can return it when searching.

More information about indexed and saved can be found here: Link

0
source

Source: https://habr.com/ru/post/983097/


All Articles