Pak*_*ira 3 lucene solr solrj morelikethis
我试图了解 Solr MorelIkeThis 是如何工作的。我已经完成的步骤 -
字段名称="path_exact" type="string" indexed="true" stored="true" termVectors="true"/>
字段名称="title" type="text_general" indexed="true" stored="true" multiValued="true" termVectors="true"/>
提到的唯一键
路径_精确
使用以下命令在 solr 中创建索引 -
{"path_exact":"id1","title":"x1"}
{"path_exact":"id2","title":"x12"}
现在,当我尝试点击以下网址时,它会返回结果,但我无法理解它到底是什么意思?是不是无法为 id1 和 id2 找到更多类似的商品?如果是,那么我在这里缺少什么?
http://:/solr/collection2/select?q=x1*&mlt=true&mlt.fl=title&wt=xml
结果 -
<lst name="moreLikeThis">
<result name="id1" numFound="0" start="0"/>
<result name="id2" numFound="0" start="0"/>
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助!
我对您究竟做了什么感到有些困惑,但是如果您想设置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>
<!--Minimum 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>
Run Code Online (Sandbox Code Playgroud)
然后在 Solr 上做一个普通的 HTTP 请求:
http://localhost:8983/solr/mlt?q="myquery"
Run Code Online (Sandbox Code Playgroud)
或者只是在向“/select”发送请求时设置“&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
Run Code Online (Sandbox Code Playgroud)