Solr:从查询响应获取排序规则

Solr:从查询响应获取排序规则,solr,spell-checking,collation,Solr,Spell Checking,Collation,我正在尝试配置SOLR拼写检查。我的请求和回应似乎很有效。唯一的问题是如何从响应中获取排序规则 这是我的回答中具有排序规则的部分。 我使用API中的哪些方法来提取3个排序规则 <str name="collation">ipod tough</str> <str name="collation">ipad tough</str> <str name="collation">wood tough</str> <s

我正在尝试配置SOLR拼写检查。我的请求和回应似乎很有效。唯一的问题是如何从响应中获取排序规则

这是我的回答中具有排序规则的部分。 我使用API中的哪些方法来提取3个排序规则

 <str name="collation">ipod tough</str>
 <str name="collation">ipad tough</str>
 <str name="collation">wood tough</str>
 <str name="collation">food tough</str>
ipod
ipad硬朗
木材坚韧
食物坚韧
这是我目前使用的方法:

List<String> suggestedTermsList = new ArrayList<String>();
if(aQueryResponse == null) {
  return suggestedTermsList;
}

try {
  SpellCheckResponse spellCheckResponse = aQueryResponse.getSpellCheckResponse();
  if(spellCheckResponse == null) {
    throw new Exception("No SpellCheckResponse in QueryResponse");
  }  

 List<Collation> collationList = spellCheckResponse.getCollatedResults();

  for(Collation c : collationList){
    suggestedTermsList.add(c.getCollationQueryString());
  }

}catch(Exception e) {
  Trace.Log("SolrSpellCheck",Trace.HIGH, "Exception: " + e.getMessage());
}
return suggestedTermsList;
List suggestedTermsList=new ArrayList();
if(aQueryResponse==null){
返回建议的术语列表;
}
试一试{
SpellCheckResponse SpellCheckResponse=aQueryResponse.getSpellCheckResponse();
if(拼写检查响应==null){
抛出新异常(“QueryResponse中没有拼写检查响应”);
}  
List collationList=spellCheckResponse.getCollatedResults();
for(排序规则c:排序规则列表){
添加(c.getCollationQueryString());
}
}捕获(例外e){
Log(“SolrSpellCheck”,Trace.HIGH,“Exception:+e.getMessage());
}
返回建议的术语列表;
我的响应标题如下所示:

拼写检查={suggestions={ipood={numFound=5,startOffset=0,endOffset=5,suggestion=[ipod,ipad,wood,food,pod]},collation=ipod tough,collation=ipad tough,collation=wood tough,collation=food tough}


我得到了4个排序规则,我想将它们添加到一个列表suggestedTermsList中,然后返回到调用代码。现在我的ArrayList有4个排序规则,但它只重复了最后一个排序规则4次。i、 e food tough-四次。

我想您应该调用QueryResponse.getSpellCheckResponse()并从那里开始。以下是一些您可能会觉得有用的文档链接:


您没有说明正在使用什么客户端API,也没有说明如何读取响应。你在用SolrJ吗?嗨,迈克,请看看我最新的问题。嗯,这看起来很奇怪。我从没听说过这样的虫子。您确定没有在未显示的外层中错误地报告它们吗?我最后添加了拼写检查。collatedExtendedResults=true,它返回了正确的排序规则。我从lucene论坛得到了帮助。