0

当我在浏览器上对 solr 运行拼写检查查询时,我可以看到带有建议和排序规则的响应,但是,当我使用 solr4j 运行时,我只看到建议 - 没有排序规则。

询问

http://localhost:8080/solr/peeps/mySuggest?qt=%2FmySuggest&distrib=false&df=myFieldLookup&q=myFieldLookup:sc+ma&start=0&rows=0

回复

<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">3</int>
</lst>
<result name="response" numFound="0" start="0"/>
<lst name="spellcheck">
<lst name="suggestions">
<lst name="sc">
<int name="numFound">1</int>
<int name="startOffset">32</int>
<int name="endOffset">34</int>
<arr name="suggestion">
<str>science</str>
</arr>
</lst>
<lst name="ma">
<int name="numFound">2</int>
<int name="startOffset">35</int>
<int name="endOffset">37</int>
<arr name="suggestion">
<str>management</str>
<str>master</str>
</arr>
</lst>
<lst name="collation">
<str name="collationQuery">myFieldLookup:science management</str>
<int name="hits">1</int>
<lst name="misspellingsAndCorrections">
<str name="sc">science</str>
<str name="ma">management</str>
</lst>
</lst>
<lst name="collation">
<str name="collationQuery">myFieldLookup:science master</str>
<int name="hits">1</int>
<lst name="misspellingsAndCorrections">
<str name="sc">science</str>
<str name="ma">master</str>
</lst>
</lst>
</lst>
</lst>
</response>

但是当我从 solr4j 调用时,除了响应的“整理”部分之外,我得到了上述所有内容!

所以,我从浏览器中尝试了这个 URL(添加了 wt=javabin 和版本)来查看 solr4j 正在接收什么。

http://localhost:8080/solr/peeps/mySuggest?qt=%2FmySuggest&distrib=false&df=myFieldLookup&q=myFieldLookup:sc+ma&start=0&rows=0&wt=javabin&version=2

下载了一个文件,我用文本编辑器打开它

£‡.responseHeader¢‡&amp;status‡%QTimeB‡(responseÉ``ć*spellcheck°‡+suggestionsƒ‡"sc§‡(numFoundA‡+startOffsetP‡)endOffsetR‡*suggestionÅ'science‡"ma§ËBÈSÍUÎÇ*management&master‡)collation√‡.collationQuery?myFieldLookup:science management‡$hitsA‡:misspellingsAndCorrections¬Á'scienceÏ*managementÌ√Ó?myFieldLookup:science masterÔA¬Á'scienceÏ&master

它不可读,但是,我可以在那里看到“排序规则”这个词!那么,为什么 Solr4j 不接受呢?

4

1 回答 1

0

您想利用 SolrJ SpellCheckResponse对象来访问排序规则响应。您应该能够使用以下方法看到这一点:

 ...
 QueryResponse response = solr.query(params);
 SpellCheckResponse spellCheckResponse = response.getSpellCheckResponse(); 
 List<SpellCheckResponse.Collation> collations = spellCheckResponse.getCollatedResults();
于 2013-06-10T19:52:14.067 回答