我正在努力了解Solr MorelIke这是如何运作的。我已经完成的步骤 -
field name =“path_exact”type =“string”indexed =“true”stored =“true”termVectors =“true”/>
field name =“title”type =“text_general”indexed =“true”stored =“true”multiValued =“true”termVectors =“true”/>
提到uniqueKey
path_exact
使用以下命令 -
在solr中创建索引{“path_exact”:“id1”,“title”:“x1”}
{“path_exact”:“id2”,“title”:“x12”}
现在,当我试图点击下面的url然后它返回结果但我无法理解它究竟是什么意思?是否无法为id1和id2找到更多的项目?如果,是的,那么我在这里缺少什么?
的http://:/?的solr / collection2 /选择Q = X1 *安培; MLT =真安培; mlt.fl =标题&安培;重量= XML
结果 -
<lst name="moreLikeThis">
<result name="id1" numFound="0" start="0"/>
<result name="id2" numFound="0" start="0"/>
感谢您的帮助!
答案 0 :(得分:3)
我对你所做的事情感到有点困惑,但是如果你想设置MLT,你可以在你的核心目录中的solrconfig.xml中添加一个请求处理程序(我假设Solr 4.0和以上)。所以有些东西:
<!-- More Like This -->
<requestHandler name="/mlt" class="solr.MoreLikeThisHandler">
<lst name="defaults">
<!--similar documents defaults-->
<!--The fields to use for similarity-->
<str name="mlt.fl">article_title, abstract_text</str>
<!--Minimum Term Frequency - the frequency below which terms will be ignored in the source doc.-->
<str name="mlt.mintf">2</str>
<!--Minimum Document Frequency - the frequency at which words will be ignored which do not occur in at least this many docs.-->
<str name="mlt.mintf">5</str>
<!--minimum word length below which words will be ignored.-->
<str name="mlt.mintf">0</str>
<!--maximum word length above which words will be ignored.-->
<str name="mlt.mintf">0</str>
<!--maximum number of query terms that will be included in any generated query.-->
<str name="mlt.mintf">25</str>
<!--maximum number of query terms that will be included in any generated query.-->
<str name="mlt.mintf">25</str>
</lst>
</requestHandler>
然后只需在Solr上执行正常的HTTP请求:
http://localhost:8983/solr/mlt?q="myquery"
或者在向“/ select?”发送请求时设置“&amp; mlt = true”标志。请求处理程序,例如solr wiki提供的示例:
http://localhost:8983/solr/select?q=apache&mlt=true&mlt.fl=manu,cat&mlt.mindf=1&mlt.mintf=1&fl=id,score