You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@solr.apache.org by gnandre <ar...@gmail.com> on 2023/01/12 02:51:46 UTC

FileBasedSpellChecker always returns "correctlySpelled": false

Hi,

I am using Solr 8.5.2 and when I use FileBasedSpellChecker, I
always get "correctlySpelled": false even if the spellcheck.q value exists
in the file.

Apart from that it is working as expected. When I give slightly misspelled
term to spellcheck.q param, it returns the valid suggestion present in the
file.

Following is the minimal setting with which I could reproduce the issue:

  <requestHandler name="/spellcheck_filter_custom" class=
"org.apache.solr.handler.component.SearchHandler">
    <lst name="defaults">
      <str name="spellcheck.dictionary"
>fileBasedSpellChecker_custom_spellcheck_en</str>
      <str name="spellcheck">true</str>
      <str name="spellcheck.extendedResults">true</str>
    </lst>
    <arr name="last-components">
      <str>spellcheck_filter_custom</str>
    </arr>
  </requestHandler>
  <searchComponent name="spellcheck_filter_custom" class=
"solr.SpellCheckComponent">
    <lst name="spellchecker">
      <str name="classname">solr.FileBasedSpellChecker</str>
      <str name="name">fileBasedSpellChecker_custom_spellcheck_en</str>
      <str name="sourceLocation"
>./spellcheck/custom_spellcheck_list_en.txt</str>
      <str name="characterEncoding">UTF-8</str>
      <str name="spellcheckIndexDir"
>./fileBasedSpellChecker_custom_spellcheck_en</str>
    </lst>
  </searchComponent>

And here is the custom_spellcheck_list_en.txt file contents

cleve
unit

here is the call:

http://solr:8983/solr/answers/spellcheck_filter_custom?spellcheck.q=cleve&spellcheck.build=true

And here is the response:

{"responseHeader": {"status": 0,"QTime": 61},"command": "build","response":
{"numFound": 0,"start": 0,"docs": []},"spellcheck": {"suggestions": [],"
correctlySpelled": false}}

If I pass a slightly incorrect term, it works fine:
http://solr:8983/solr/answers/spellcheck_filter_custom?spellcheck.q=clev&spellcheck.build=true

{"responseHeader": {"status": 0,"QTime": 34},"command": "build","response":
{"numFound": 0,"start": 0,"docs": []},"spellcheck": {"suggestions": ["clev",
{"numFound": 1,"startOffset": 0,"endOffset": 4,"suggestion": ["cleve"]}],"
correctlySpelled": false}}