MoreLikeThis没有返回

问题描述:

我想要的Solr的MoreLikeThis功能类似文件的各个领域:MoreLikeThis没有返回

http://localhost:8983/solr/gettingstarted_shard1_replica1/select?qt=mlt&q=id:31&mlt=true&mlt.fl=firstName,lastName&mlt.mindf=1&mlt.mintf=1&mlt.count=10

这是工作,但响应的样子以下:

<response> 
<lst name="responseHeader"> 
     ... //removed for brevity 
</lst> 
<result name="response" numFound="1" start="0" maxScore="1.0"> 
    <doc> 
     <str name="id">31</str> 
     <str name="firstName">Alex Luis Armstrong</str> 
     <str name="lastName">Major Wolf</str> 
     <long name="_version_">1534338957920174080</long> 
    </doc> 
</result> 
<lst name="moreLikeThis"> 
    <result name="31" numFound="4" start="0" maxScore="0.419522"> 
     <doc> 
     <str name="id">32</str> 
     <float name="score">0.419522</float> 
     </doc> 
     <doc> 
     <str name="id">33</str> 
     <float name="score">0.0254616</float> 
     </doc> 
    </result> 
</lst> 
</response> 

为什么不firstName,并在结果IDS 32和33返回lastName

字段类型: enter image description here enter image description here enter image description here

其实我不知道发生了什么,但有两个地方我建议进行调查。

  1. 在您的查询字符串我看到有一个参数qt=mlt。指定的请求处理程序或查询类型参数(solrconfig.xml)可以覆盖您的参数。所以我建议只删除qt参数并尝试添加mlt.match.include=true。此参数指定响应是否应包含匹配的文档。
  2. schema.xml,特别是我建议张贴宣布firstNamelastName的部分。

使用fl参数指定您想返回的字段,就像使用典型(非mlt)查询一样。

mlt.fl参数只是指示Solr只考虑具有类似firstNamelastName字段的文档。

如果你想要这些字段也返回,通过...&fl=firstName,lastName&...