Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get MoreLikeThis result

I'm trying to understand how Solr MorelIkeThis works. Steps I've done -

  1. In schema.xml I've written -

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"/>

  1. Mentioned uniqueKey

    path_exact

  2. Created index in solr by using below command -

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

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

  3. Now when I'm trying to hit the below url then it return result but I'm not able to understand what does it mean exactly? Is it not able to find morelikethis item for id1 and id2? If, yes, then what I'm missing here?

    http://:/solr/collection2/select?q=x1*&mlt=true&mlt.fl=title&wt=xml

Result -

 <lst name="moreLikeThis">
     <result name="id1" numFound="0" start="0"/>
    <result name="id2" numFound="0" start="0"/>

Thanks for your help!

like image 629
Pakira Avatar asked Oct 27 '25 11:10

Pakira


1 Answers

I'm a bit confused as to what you did exactly, but if you want to set up MLT you can either add a request handler to the solrconfig.xml in your core directory (Im assuming Solr 4.0 and above). So something along the lines of:

    <!-- 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>

And then just do a normal HTTP request onto Solr:

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

Or just set the "&mlt=true" flag when sending a request to the "/select?" request handler, such as the example provided by solr wiki:

http://localhost:8983/solr/select?q=apache&mlt=true&mlt.fl=manu,cat&mlt.mindf=1&mlt.mintf=1&fl=id,score
like image 151
Jorge Lazo Avatar answered Oct 29 '25 10:10

Jorge Lazo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!