2
votes

In the SOLR admin, we can see there is a spellcheck option but it is not showing the result.

How this is works with the select query.

If I searched with the spell URL direct, It gives me result as expected

http://localhost:8983/solr/prashant1/spell?q=blakc&spellcheck=on&wt=json

Result

{
  "responseHeader":{
    "status":0,
    "QTime":8},
  "response":{"numFound":0,"start":0,"docs":[]
  },
  "spellcheck":{
    "suggestions":[
      "blakc",{
        "numFound":10,
        "startOffset":0,
        "endOffset":5,
        "origFreq":0,
        "suggestion":[{
            "word":"black",
            "freq":65146},
          {
            "word":"blanc",
            "freq":151},
          {
            "word":"blake",
            "freq":10},
          {
            "word":"blac",
            "freq":2},
          {
            "word":"block",
            "freq":1863},
          {
            "word":"blanca",
            "freq":32},
          {
            "word":"blank",
            "freq":31},
          {
            "word":"blade",
            "freq":23},
          {
            "word":"blacks",
            "freq":12},
          {
            "word":"blanco",
            "freq":11}]}],
    "correctlySpelled":false,
    "collations":[]}}

But I need the same result with the select query which is not working from the SOLR admin.

Solrconfig.xml

<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
    <str name="queryAnalyzerFieldType">text_general</str>
    <!-- Multiple "Spell Checkers" can be declared and used by this
         component
      -->
    <!-- a spellchecker built from a field of the main index -->
    <lst name="spellchecker">
      <str name="name">default</str>
      <str name="field">Name</str>
      <str name="classname">solr.DirectSolrSpellChecker</str>
      <!-- the spellcheck distance measure used, the default is the internal levenshtein -->
      <str name="distanceMeasure">internal</str>
      <!-- minimum accuracy needed to be considered a valid spellcheck suggestion -->
      <float name="accuracy">0.5</float>
      <!-- the maximum #edits we consider when enumerating terms: can be 1 or 2 -->
      <int name="maxEdits">2</int>
      <!-- the minimum shared prefix when enumerating terms -->
      <int name="minPrefix">1</int>
      <!-- maximum number of inspections per result. -->
      <int name="maxInspections">5</int>
      <!-- minimum length of a query term to be considered for correction -->
      <int name="minQueryLength">4</int>
      <!-- maximum threshold of documents a query term can appear to be considered for correction -->
      <float name="maxQueryFrequency">0.01</float>
      <!-- uncomment this to require suggestions to occur in 1% of the documents
        <float name="thresholdTokenFrequency">.01</float>
      -->
    </lst>
</searchComponent>

<requestHandler name="/spell" class="solr.SearchHandler" startup="lazy">
    <lst name="defaults">
      <str name="spellcheck.dictionary">default</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>

It should work with:

http://localhost:8983/solr/prashant1/select?q=Name%3Ablakc&spellcheck.q=blakc&spellcheck=on

Is there any setting and steps to be done?

1
try adding the <arr name="last-components"> <str>spellcheck</str> </arr> to your Request HandlerAbhijit Bashetti

1 Answers

1
votes

Try by adding the spellcheck component to the standard query handler like

<requestHandler name="/select" class="solr.SearchHandler">
    <lst name="defaults">
      <str name="echoParams">explicit</str>
      <int name="rows">10</int>

    <str name="spellcheck">on</str>
      <str name="spellcheck.extendedResults">true</str>
      <str name="spellcheck.count">10</str>
    </lst>
    <arr name="last-components">
      <str>spellcheck</str>
    </arr>
</requestHandler>

You can then call it like this:

http://localhost:8983/solr/select?q=yogik&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