2

我正在使用 SOLR 的拼写检查组件来获取建议,并期望 Hits 部分从新单词中返回许多命中,但在所有情况下它都返回零命中:

    {
   "spellcheck":{
      "suggestions":[
         "pho",
         {
            "numFound":8,
            "startOffset":0,
            "endOffset":3,
            "suggestion":[
               "photo",
               "phone",
               "phone's",
               "phones",
               "photography",
               "photoimpression's",
               "photographers",
               "photos"
            ]
         },
         "collation",
         [
            "collationQuery",
            "photo",
            "hits",
            0,
            "misspellingsAndCorrections",
            [
               "pho",
               "photo"
            ]
         ],
         "collation",
         [
            "collationQuery",
            "phone",
            "hits",
            0,
            "misspellingsAndCorrections",
            [
               "pho",
               "phone"
            ]
         ],
         "collation",
         [
            "collationQuery",
            "phone's",
            "hits",
            0,
            "misspellingsAndCorrections",
            [
               "pho",
               "phone's"
            ]
         ],
         "collation",
         [
            "collationQuery",
            "phones",
            "hits",
            0,
            "misspellingsAndCorrections",
            [
               "pho",
               "phones"
            ]
         ],
         "collation",
         [
            "collationQuery",
            "photography",
            "hits",
            0,
            "misspellingsAndCorrections",
            [
               "pho",
               "photography"
            ]
         ],
         "collation",
         [
            "collationQuery",
            "photoimpression's",
            "hits",
            0,
            "misspellingsAndCorrections",
            [
               "pho",
               "photoimpression's"
            ]
         ],
         "collation",
         [
            "collationQuery",
            "photographers",
            "hits",
            0,
            "misspellingsAndCorrections",
            [
               "pho",
               "photographers"
            ]
         ],
         "collation",
         [
            "collationQuery",
            "photos",
            "hits",
            0,
            "misspellingsAndCorrections",
            [
               "pho",
               "photos"
            ]
         ]
      ]
   }
}

我的设置是:

<searchComponent class="solr.SpellCheckComponent" name="suggest">
    <lst name="spellchecker">
        <str name="name">suggest</str>
        <str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
        <str name="lookupImpl">org.apache.solr.spelling.suggest.tst.TSTLookupFactory</str>
        <str name="field">text</str>
        <float name="threshold">0.005</float>
        <str name="buildOnCommit">true</str>
    </lst>
</searchComponent>

对于我的组件和

<requestHandler class="org.apache.solr.handler.component.SearchHandler" name="/suggest">
    <lst name="defaults">
        <str name="spellcheck">true</str>
        <str name="spellcheck.dictionary">suggest</str>
        <str name="spellcheck.onlyMorePopular">true</str>
        <str name="spellcheck.count">5</str>
        <str name="spellcheck.collate">true</str>
        <str name="spellcheck.maxCollations">10</str>
        <str name="spellcheck.collateExtendedResults">true</str>
    </lst>
    <arr name="components">
        <str>suggest</str>
    </arr>
</requestHandler>

关于如何填写此内容的任何想法,以便我可以向最终用户显示#results?

4

3 回答 3

1

可能有点晚了......我遇到了同样的问题,直到我意识到我必须明确告诉 Solr运行查询,以便它可以返回hits count

你的 requestHandler 需要一个QueryComponent配置,默认名为“query”,只需将其添加到你的 requestHandler 的组件部分。

<arr name="components">
  <str>query</str>
  <str>suggest</str>
</arr>

注意:如果请求处理程序具有defType参数集(指定要使用的查询解析器),则不需要这样做。

于 2016-02-04T20:09:59.503 回答
0

将以下内容添加到 SearchHandler 配置中,然后您将获得每个排序规则的命中计数:

<str name="spellcheck.maxCollationTries">1</str>

注意:这将使整理者通过使用它们进行实际查询来验证整理,从而产生命中计数。为了使验证查询快速,他们禁用了评分和提升,并且也不加载任何存储的字段,但整理器仍在为每个整理运行额外的查询 - 如果您的maxCollations设置较高,请注意这一点。

于 2014-09-28T11:26:59.753 回答
0

查询组件默认是执行链的一部分,因此不需要显式声明。你需要的是

spellcheck.collateExtendedResults

设置为 true,您将得到正确填充的 numberOfHits 和 mispellingAndCorrections。正如其他答案中所指出的,这增加了一致的开销

于 2021-10-19T15:25:07.307 回答