1

We're trying to use Solr to correct the spelling of certain tests in a search box. We found that it works like this:

http://localhost:8080/solr/collection1/spell?q=badspelled&spellcheck=true

And it returns a set of suggested terms. But what we need is not a list of suggestions but that Solr makes a search directly using the first suggestion. Is that possible?

4

1 回答 1

1

您需要将“spellcheck.collat​​e=true”参数添加到您的第一个搜索查询中,然后在响应中使用“collat​​ion”值来触发具有该值的第二个查询。

插件页面的示例:

http://localhost:8983/solr/spell?q=price:[80 TO 100] delll ultrashar&spellcheck=true&spellcheck.extendedResults=true&spellcheck.collate=true

这将返回建议:

<lst name="spellcheck">
  <lst name="suggestions">
    <lst name="delll">
      <int name="numFound">1</int>
      <int name="startOffset">18</int>
      <int name="endOffset">23</int>
      <int name="origFreq">0</int>
      <arr name="suggestion">
        <lst>
          <str name="word">dell</str>
          <int name="freq">2</int>
        </lst>
      </arr>
    </lst>
    <lst name="ultrashar">
      <int name="numFound">1</int>
      <int name="startOffset">24</int>
      <int name="endOffset">33</int>
      <int name="origFreq">0</int>
      <arr name="suggestion">
        <lst>
          <str name="word">ultrasharp</str>
          <int name="freq">2</int>
        </lst>
      </arr>
    </lst>
    <bool name="correctlySpelled">false</bool>
    <str name="collation">price:[80 TO 100] dell ultrasharp</str>
  </lst>
</lst>

然后使用建议的查询触发另一个查询:

http://localhost:8983/solr/spell?q=price:[80 TO 100] dell ultrasharp&spellcheck=true&spellcheck.extendedResults=true&spellcheck.collate=true

拼写检查整理

于 2013-05-14T21:07:22.590 回答