首页 > 解决方案 > Solr 对包含多个单词的短语进行拼写检查

问题描述

如果“heritga festiavl”作为一个句子进行搜索,那么预期结果应该是“heritage Festival”或“heritag festi”,但建议是针对每个单词单独给出的。是否可以将建议作为单个短语获得。如果为单词添加准确性,则会清楚地给出建议,但准确性会因单词而异。例如,如果准确度 0.86 适用于 word Heritage 以显示结果,但相同的准确度不适用于 word heart。需要有意义的建议。

我得到的示例结果建议:

{
  "responseHeader": {
    "status": 0,
    "QTime": 37
  },
  "command": "build",
  "response": {
    "numFound": 0,
    "start": 0,
    "docs": []
  },
  "spellcheck": {
    "suggestions": [
      "heritg",
      {
        "numFound": 10,
        "startOffset": 0,
        "endOffset": 7,
        "origFreq": 0,
        "suggestion": [
          {
            "word": "herita",
            "freq": 7
          },
          {
            "word": "heritag",
            "freq": 7
          },
          {
            "word": "herit",
            "freq": 7
          },
          {
            "word": "heritage",
            "freq": 7
          },
          {
            "word": "hearing",
            "freq": 6
          },
          {
            "word": "hiring",
            "freq": 5
          },
          {
            "word": "hertz",
            "freq": 1
          },
          {
            "word": "heig",
            "freq": 12
          },
          {
            "word": "heri",
            "freq": 7
          },
          {
            "word": "hert",
            "freq": 1
          }
        ]
      },
      "heritga",
      {
        "numFound": 4,
        "startOffset": 0,
        "endOffset": 7,
        "origFreq": 0,
        "suggestion": [
          {
            "word": "heritag",
            "freq": 7
          },
          {
            "word": "herita",
            "freq": 7
          },
          {
            "word": "heritage",
            "freq": 7
          },
          {
            "word": "herit",
            "freq": 7
          }
        ]
      },
      "festia",
      {
        "numFound": 5,
        "startOffset": 8,
        "endOffset": 16,
        "origFreq": 0,
        "suggestion": [
          {
            "word": "festiv",
            "freq": 14
          },
          {
            "word": "festiva",
            "freq": 14
          },
          {
            "word": "festi",
            "freq": 14
          },
          {
            "word": "festival",
            "freq": 14
          },
          {
            "word": "fest",
            "freq": 14
          }
        ]
      },
      "festiav",
      {
        "numFound": 4,
        "startOffset": 8,
        "endOffset": 16,
        "origFreq": 0,
        "suggestion": [
          {
            "word": "festiva",
            "freq": 14
          },
          {
            "word": "festiv",
            "freq": 14
          },
          {
            "word": "festival",
            "freq": 14
          },
          {
            "word": "festi",
            "freq": 14
          }
        ]
      },
      "festiavl",
      {
        "numFound": 3,
        "startOffset": 8,
        "endOffset": 16,
        "origFreq": 0,
        "suggestion": [
          {
            "word": "festival",
            "freq": 14
          },
          {
            "word": "festiva",
            "freq": 14
          },
          {
            "word": "festiv",
            "freq": 14
          }
        ]
      }
    ],
    "correctlySpelled": false,
    "collations": []
  }
}

标签: .netsolrsitecore

解决方案


关于短语的需要,您可以尝试按照文档spellcheck.collate中的说明设置为。true


推荐阅读