Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Request handle solrconfig.xml Spellchecker

I am trying to set up spellchecker, according to solr documentation. But when I am testing, I don't have any suggestion. My piece of code follows:

 <searchComponent name="spellcheck" class="solr.SpellCheckComponent">

    <str name="queryAnalyzerFieldType">textSpell</str>

    <lst name="spellchecker">
      <str name="classname">solr.IndexBasedSpellChecker</str>
      <str name="name">default</str>
      <str name="field">name</str>
      <str name="spellcheckIndexDir">./spellchecker</str>
    </lst>
    <str name="queryAnalyzerFieldType">textSpell</str>

  </searchComponent>


 <requestHandler name="/spellcheck" class="solr.SearchHandler">
    <lst name="defaults">
      <str name="echoParams">explicit</str>
      <!-- Optional, must match spell checker's name as defined above, defaults to "default" -->
      <str name="spellcheck.dictionary">default</str>
      <!-- omp = Only More Popular -->
      <str name="spellcheck.onlyMorePopular">false</str>
      <!-- exr = Extended Results -->
      <str name="spellcheck.extendedResults">false</str>
      <!--  The number of suggestions to return -->
      <str name="spellcheck.count">1</str>
    </lst>
    <arr name="last-components">
      <str>spellcheck</str>
    </arr>
  </requestHandler>

The query I send to Solr:
q=%2B%28text%3A%28gasal%29%29&suggestField=contentOriginal&ontologySeed=gasal&spellcheck.build=true&spellcheck.q=gasal&spellcheck=true&spellcheck.collate=true&hl=true&hl.snippets=5&hl.fl=text&hl.fl=text&rows=12&start=0&qt=%2Fsuggestprobabilistic

Does anybody know why?? Thanks in advance

like image 429
Blanca Hdez Avatar asked Oct 19 '10 09:10

Blanca Hdez


1 Answers

First, don't repeat queryAnalyzerFieldType twice in the component configuration.

It is recommended not to use a /spellcheck handler but instead to bind the spellcheck component to the standard query handler (or dismax if it is what you use) like this:

<requestHandler name="standard" class="solr.SearchHandler" default="true">
 <lst name="defaults">
    ...
 </lst>   
 <arr name="last-components">
    <str>spellcheck</str>
    ...         
 </arr>
</requestHandler>

You can then call it like this:
http://localhost:8983/solr/select?q=komputer&spellcheck=true

Also don't forget to build the spellcheck dictionary before you use it:
http://localhost:8983/solr/select/?q=*:*&spellcheck=true&spellcheck.build=true

You can force the dictionary to build at each commit by configuring it in the component:

<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
 <str name="queryAnalyzerFieldType">textSpell</str>
 <lst name="spellchecker">
  <str name="classname">solr.IndexBasedSpellChecker</str>
  <str name="name">default</str>
  <str name="field">name</str>
  <str name="spellcheckIndexDir">./spellchecker1</str>
  <str name="buildOnCommit">true</str>
 </lst>
</searchComponent>

Finally, make sure that your name field is really an indexed field of type textSpell and that it contains enough content to build a good dictionary. In my case, I have a field named spellchecker that is populated from a couple of fields of my index (using copyField instructions in the schema).

like image 108
Pascal Dimassimo Avatar answered Nov 15 '22 08:11

Pascal Dimassimo