0
votes

I'm in the process of migration to Solr Cloud from a master-slave configuration. The Solr version I'm migrating to is 4.4. I've 2 shards with 1 replica each. I'm facing one issue with distributed spelling suggestion. I've turned on the spelling component inside my request handler. The idea is to bring back suggestion (if any) as part of the query response.


<str name="spellcheck">on</str> 
   <str name="spellcheck.collate">true</str> 
   <str name="spellcheck.onlyMorePopular">false</str> 
   <str name="spellcheck.extendedResults">false</str> 
   <str name="spellcheck.count">1</str> 
   <str name="spellcheck.dictionary">default</str> 
  </lst> 
  <!-- append spellchecking to our list of components --> 
  <arr name="last-components"> 
   <str>spellcheck</str> 
  </arr>

The spellcheck search component is pretty standard as well.


<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
    <str name="queryAnalyzerFieldType">spell</str>
    <!-- a spellchecker built from a field of the main index -->
    <lst name="spellchecker">
        <str name="name">default</str>
        <str name="field">text</str>
        <str name="classname">solr.DirectSolrSpellChecker</str>
        <str name="distanceMeasure">internal</str>
        <float name="accuracy">0.5</float>
        <int name="maxEdits">2</int>
        <int name="minPrefix">1</int>
        <int name="maxInspections">5</int>
        <int name="minQueryLength">4</int>
        <float name="maxQueryFrequency">0.01</float>
        <!-- uncomment this to require suggestions to occur in 1% of the documents
               <float name="thresholdTokenFrequency">.01</float>
      -->
    </lst>

    <!-- a spellchecker that can break or combine words.  See "/spell" handler below for usage -->
    <lst name="spellchecker">
        <str name="name">wordbreak</str>
        <str name="classname">solr.WordBreakSolrSpellChecker</str>     
        <str name="field">text</str>
        <str name="combineWords">true</str>
        <str name="breakWords">true</str>
        <int name="maxChanges">10</int>
    </lst>
</searchComponent>

I ran a spellcheck.build=true in both the shards. Now,if I run a query,


http://testhost.com:8983/solr/browse?q=dellll
the response doesn't return any suggestion. But, if I explicitly add distrib=false , I get the suggestion back

http://testhost.com:8983/solr/browse?q=dellll&distrib=false

This sort of the defeats the purpose as my query needs to be distributed and I don't want a separate query just for a spell check.

Any pointer on this will be appreciated.

  • Thanks
1

1 Answers

1
votes

I've found the solution.As a reference for others looking into the solution, here's what you need to do.

For spelling suggestion to work in a distributed Solr environment, you need to add shards.qt in your query. It should be set to the name of the request handler you are using. For e.g if you are using /select request handler, then you need to use /spell request handler. The query would look like :


http://testhost.com:8983/solr/select?q=dellll&shards.qt=/spell

For custom request handlers, the qt should be the same as the request handler.


http://testhost.com:8983/solr/customhandler?q=dellll&shards.qt=/customhandler