How to make Solr's spell checker ignore case?

喜夏-厌秋 提交于 2019-12-24 05:36:42

问题


How do you ask the example spellchecker to ignore case ? I am using all defaults shown in the demo.
Now I see that if I type Ancient, it asks "did you mean ancient ? " What do I do ?

ps : I don't have anything that has the word "spell" in my schema.xml!!!! How is it working ?


回答1:


The schema should have a field type called "spell" that is used for spell checking. This will lowercase all words used by the spellchecker so you don't have to worry about case. Here is an example of how to use this field type.

Create a field in your schema for spell checking.

<field name="spelling" type="spell" indexed="true" stored="false"/>

And then use a copy field to copy data into this field. The example, the code below will copy the "product_name" field into the spell checker.

<copyField source="product_name" dest="spelling"/>

Edit...

Sorry... I though the "spell" field type was in the default schema. Add this to your schema in the same section as the other fieldType tags.

<fieldType name="spell" class="solr.TextField" positionIncrementGap="100">
  <analyzer type="index">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" 
        words="stopwords.txt"/>
    <filter class="solr.StandardFilterFactory"/>
        <filter class="solr.LowerCaseFilterFactory" />
    <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" 
        ignoreCase="true" expand="true"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" 
        words="stopwords.txt"/>
    <filter class="solr.StandardFilterFactory"/>
        <filter class="solr.LowerCaseFilterFactory" />
    <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
  </analyzer>
</fieldType>



回答2:


Please post your solrconfig.xml - I think that will provide a clue.

My best guess will be that solrconfig.xml contains the config for the spellchecker (link) which specifies the field to be used for generating spelling suggestions. That field does not have a LowerCaseFilter in your schema.xml



来源:https://stackoverflow.com/questions/5151607/how-to-make-solrs-spell-checker-ignore-case

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!