koponk
koponk

Reputation: 472

Solr conditional spellcheck

Environment : PHP, solr client, solr 7.2.1

I want to run my spellchecker if my /select query return nothing. Can i do it in a single query? Or i have to make conditional in my PHP,

im using index based spell checker :

<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
    <str name="queryAnalyzerFieldType">text_general</str>
    <lst name="spellchecker">
      <str name="name">indexchecker</str>
      <str name="classname">solr.IndexBasedSpellChecker</str>
      <str name="spellcheckIndexDir">./spellchecker</str>
      <str name="field">pagetext</str>
      <str name="buildOnCommit">false</str>
      <!-- optional elements with defaults
      <str name="comparatorClass">freq</str> freq score(default)
      <str name="distanceMeasure">org.apache.lucene.search.spell.LevensteinDistance</str>
      <str name="distanceMeasure">org.apache.lucene.search.spell.JaroWinklerDistance</str>
      <str name="accuracy">0.5</str>
      -->
    </lst>
</searchComponent>

Upvotes: 0

Views: 230

Answers (1)

MatsLindh
MatsLindh

Reputation: 52832

Yes, as long as you're running the select with spellcheck=true, the result will be present in the same request.

You can tune when you want the spellchecker to be invoked by adding a few parameters to your request:

spellcheck.maxResultsForSuggest

The maximum number of hits the request can return in order to both generate spelling suggestions and set the "correctlySpelled" element to "false".

spellcheck.onlyMorePopular

Limits spellcheck responses to queries that are more popular than the original query.

Upvotes: 1

Related Questions