8
votes

I'm implementing an search service with SOLR 4.10 and would like to provide search suggestions based on the already specified term. Pretty standard feature for todays search applications...

What I want is that SOLR searches case insensitive for suggestions BUT return the original case string, which seems not to be possible... search: abc return: AbCdEfG

when I use the "LowerCaseFilterFactory" the search is case insensitive but the returned suggestions are all lowercased. When I remove it the returned suggestions are original but the search is not case insensitive.... =/

I added this request handler and search component to my solrconfig.xml:

<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>
1
Do you have any news here?dtrunk

1 Answers

0
votes

I think if you set the "stored" attribute to true on the fields you want the original value returned and re-index then it will solve your problem.

If the index attribute is set to true on a field Solr only stores the tokens that it gets from the document analysis in its index. So your Solr index only contains the case insensitive tokens taken from your documents. If stored is also set to true then it stores the original term somewhere in the index it creates so it can return it upon searching.

More information about indexed vs. stored can be found here: Link