我正在使用Solarium建议器来获取建议,我期望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?
答案 0 :(得分:0)
将以下内容添加到SearchHandler配置中,然后您将获得每个归类hitcounts:
<str name="spellcheck.maxCollationTries">1</str>
注意:这将使整理程序通过使用它们执行实际查询来验证排序规则,从而生成hitcounts。为了使验证查询更快,他们已经禁用了评分和提升,并且也没有加载任何存储的字段,但是整理者仍然在每次整理时运行额外的查询 - 如果你有一个高maxCollations
的话需要注意设置。
答案 1 :(得分:0)
可能有点迟了......我遇到了同样的问题,直到我意识到我必须明确告诉Solr 运行 查询,以便它可以返回命中数。
您的requestHandler需要QueryComponent
个配置,默认配置名为“query”,只需将其添加到您的requestHandler的组件部分。
<arr name="components">
<str>query</str>
<str>suggest</str>
</arr>
注意:如果请求处理程序设置了defType
param(指定要使用的查询解析器),则不需要这样做。