You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Erik Holstad <er...@gmail.com> on 2008/10/09 03:45:35 UTC

Using the more like this feature in solrj.

Hi!
Have been going though the documentation for the more like this/these
feature
but haven't found anything about how to use it in Solrj.

Regards Erik

Re: Using the more like this feature in solrj.

Posted by Erik Holstad <er...@gmail.com>.
Thanks Bruce!
That worked very well.

Erik

On Wed, Oct 8, 2008 at 9:14 PM, Bruce Ritchie <br...@jivesoftware.com>wrote:

> Erik,
>
> I just got this to work myself and the documentation was only partially
> helpful in figuring it out. Two main points on making this work via sor1j:
>
> #1 - Define the mlt handles in solrconfig.xml (it's not defined in the
> example solrconfig.xml I was using):
>
> <requestHandler name="/mlt" class="solr.MoreLikeThisHandler" />
>
> #2 - with Solrj, access the mlt handler via something similar to the
> following:
>
> query.setQueryType("/" + MoreLikeThisParams.MLT);
> query.set(MoreLikeThisParams.MATCH_INCLUDE, false);
> query.set(MoreLikeThisParams.MIN_DOC_FREQ, 1);
> query.set(MoreLikeThisParams.MIN_TERM_FREQ, 1);
> query.set(MoreLikeThisParams.SIMILARITY_FIELDS, "subject,body");
> query.setQuery("Your query here or in my case the unique key field:value");
>
> Note that the two lines:
>
> query.set(MoreLikeThisParams.MIN_DOC_FREQ, 1);
> query.set(MoreLikeThisParams.MIN_TERM_FREQ, 1);
>
> seem to be required for mlt to work - not sure why. Also, the fields that
> you use to determine similarity should be stored with termVectors=true and
> stored=true.
>
>
> All the best,
>
> Bruce Ritchie
>
>
> -----Original Message-----
> From: Erik Holstad [mailto:erikholstad@gmail.com]
> Sent: Wednesday, October 08, 2008 9:46 PM
> To: solr-user@lucene.apache.org
> Subject: Using the more like this feature in solrj.
>
> Hi!
> Have been going though the documentation for the more like this/these
> feature but haven't found anything about how to use it in Solrj.
>
> Regards Erik
>
> No virus found in this incoming message.
> Checked by AVG - http://www.avg.com
> Version: 8.0.173 / Virus Database: 270.7.6/1715 - Release Date: 10/8/2008
> 7:19 PM
>

RE: Using the more like this feature in solrj.

Posted by Bruce Ritchie <br...@jivesoftware.com>.
Erik,

I just got this to work myself and the documentation was only partially helpful in figuring it out. Two main points on making this work via sor1j:

#1 - Define the mlt handles in solrconfig.xml (it's not defined in the example solrconfig.xml I was using):

<requestHandler name="/mlt" class="solr.MoreLikeThisHandler" />

#2 - with Solrj, access the mlt handler via something similar to the following:

query.setQueryType("/" + MoreLikeThisParams.MLT);
query.set(MoreLikeThisParams.MATCH_INCLUDE, false);
query.set(MoreLikeThisParams.MIN_DOC_FREQ, 1);
query.set(MoreLikeThisParams.MIN_TERM_FREQ, 1);
query.set(MoreLikeThisParams.SIMILARITY_FIELDS, "subject,body");
query.setQuery("Your query here or in my case the unique key field:value");

Note that the two lines:

query.set(MoreLikeThisParams.MIN_DOC_FREQ, 1);
query.set(MoreLikeThisParams.MIN_TERM_FREQ, 1);

seem to be required for mlt to work - not sure why. Also, the fields that you use to determine similarity should be stored with termVectors=true and stored=true.


All the best,

Bruce Ritchie


-----Original Message-----
From: Erik Holstad [mailto:erikholstad@gmail.com]
Sent: Wednesday, October 08, 2008 9:46 PM
To: solr-user@lucene.apache.org
Subject: Using the more like this feature in solrj.

Hi!
Have been going though the documentation for the more like this/these feature but haven't found anything about how to use it in Solrj.

Regards Erik

No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.173 / Virus Database: 270.7.6/1715 - Release Date: 10/8/2008 7:19 PM