Solr 4.0 How can I change the spellchecker analyse

2019-02-15 15:19发布

问题:

I've just upgraded from 3.6.1 to 4.0 solr and the spelchecker stopped working. I'm using the standard config /spell request handler to test the spellchecking.

I keep getting the "All checkers need to use the same Analyzer" error. (https://svn.apache.org/repos/asf/lucene/dev/trunk/solr/core/src/java/org/apache/solr/spelling/ConjunctionSolrSpellChecker.java)

How can I change the spellchecker analysers so they are all the same?

This is the handler I'm using:

  <requestHandler name="/spell" class="solr.SearchHandler" startup="lazy">
    <lst name="defaults">
      <str name="df">text</str>
      <!-- Solr will use suggestions from both the 'default' spellchecker
           and from the 'wordbreak' spellchecker and combine them.
           collations (re-written queries) can include a combination of
           corrections from both spellcheckers -->
      <str name="spellcheck.dictionary">default</str>
      <str name="spellcheck.dictionary">wordbreak</str>
      <str name="spellcheck">on</str>
      <str name="spellcheck.extendedResults">true</str>       
      <str name="spellcheck.count">10</str>
      <str name="spellcheck.alternativeTermCount">5</str>
      <str name="spellcheck.maxResultsForSuggest">5</str>       
      <str name="spellcheck.collate">true</str>
      <str name="spellcheck.collateExtendedResults">true</str>  
      <str name="spellcheck.maxCollationTries">10</str>
      <str name="spellcheck.maxCollations">5</str>         
    </lst>
    <arr name="last-components">
      <str>spellcheck</str>
    </arr>
</requestHandler>

I know that this is not the way to use it in production.

回答1:

The answer lies in the configuration of the spell check "searchComponent" in solrconfig.xml. There, each spellchecker entry should have the same value for the "field" and/or "fieldType" attributes.



标签: java solr