3

我试图了解 Solr MorelIkeThis 是如何工作的。我已经完成的步骤 -

  1. 在 schema.xml 我写过 -

字段名称="path_exact" type="string" indexed="true" stored="true" termVectors="true"/>

字段名称="title" type="text_general" indexed="true" stored="true" multiValued="true" termVectors="true"/>

  1. 提到的 uniqueKey

    path_exact

  2. 使用以下命令在 solr 中创建索引 -

    {"path_exact":"id1","title":"x1"}

    {"path_exact":"id2","title":"x12"}

  3. 现在,当我尝试点击以下网址时,它会返回结果,但我无法理解这到底是什么意思?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"/>

谢谢你的帮助!

4

1 回答 1

7

我对您到底做了什么感到有些困惑,但是如果您想设置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>

然后对 Solr 执行一个普通的 HTTP 请求:

http://localhost:8983/solr/mlt?q="myquery"

或者在向“/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
于 2015-03-25T05:07:16.493 回答