Hi All,

I have been looking for the solution to the following problem for days.

I'm using the Solr's SpellCheck component.
The used version of Solr is 8.11.1.

I have prepared a minimal example for demonstrate my issue:

I have created a new core. The relevant part of this core's config is:
<lst name="spellchecker">
      <str name="name">default</str>
      <str name="field">text</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>


1. Firstyl, I have inserted a document with the following content:
{
  "text": "spellcheck, spelcheck"
}
Then I have run a query with this parameters:
http://localhost:8983/solr/test/spell/?q=text:spellcheck&spellcheck.q=spellcheck&spellcheck=true&df=text&wt=json

The received response is the following:
{
  "responseHeader":{
    "status":0,
    "QTime":37},
  "response":{"numFound":1,"start":0,"numFoundExact":true,"docs":[
      {
        "text":["spellcheck, spelcheck"],
        "id":"bd30834b-e439-4cf1-bb0c-79f2fe3a0ab8",
        "_version_":1722933470809817088}]
  },
  "spellcheck":{
    "suggestions":[
      "spellcheck",{
        "numFound":1,
        "startOffset":0,
        "endOffset":10,
        "origFreq":1,
        "suggestion":[{
            "word":"spelcheck",
            "freq":1}]}],
    "correctlySpelled":false,
    "collations":[
      "collation",{
        "collationQuery":"spelcheck",
        "hits":1,
        "misspellingsAndCorrections":[
          "spellcheck","spelcheck"]}]}}

So the spell checking works fine.


2. I have added a new document:
{
  "text": "other text"
}

After repeating the previous query, the response is the same. This is the
expected operation.


3. I added the first document to the db again, so there are already 3 docs.

Then the response for the query is the following:
{
  "responseHeader":{
    "status":0,
    "QTime":3},
  "response":{"numFound":2,"start":0,"numFoundExact":true,"docs":[
      {
        "text":["spellcheck, spelcheck"],
        "id":"bd30834b-e439-4cf1-bb0c-79f2fe3a0ab8",
        "_version_":1722933470809817088},
      {
        "text":["spellcheck, spelcheck"],
        "id":"7185a7b7-b6e2-4b22-bbd8-f7a6e5d1dd58",
        "_version_":1722933550886420480}]
  },
  "spellcheck":{
    "suggestions":[],
    "correctlySpelled":false,
    "collations":[]}}

It doesn't contain suggestions and collations.

Can you explain the reason for this? What do I need to do to get the
expected result?


Thanks,
Andras

Reply via email to