MLT using the Java API

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

MLT using the Java API

Dan Tuffery
I'm trying to get the MLT feature working via the Java API, here is my request:

SearchResponse searchResponse = client.moreLikeThis(moreLikeThisRequest(index).type(type)
            .id(1)
             .fields("text")
            .minTermFreq(1)
            .minDocFreq(1))
            .actionGet();

I've made sure that document 1 and other documents in the index contain the word "chicago" in the text field, but it is always returning zero hits.

The 'text' field is indexed and has "term_vectors:true"

Am I missing something here?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: MLT using the Java API

vineeth mohan
How many documents are there in the index ?

Try
            .minTermFreq(0)
            .minDocFreq(0))

On Tue, Jun 4, 2013 at 1:58 AM, es newbie <[hidden email]> wrote:
I'm trying to get the MLT feature working via the Java API, here is my request:

SearchResponse searchResponse = client.moreLikeThis(moreLikeThisRequest(index).type(type)
            .id(1)
             .fields("text")
            .minTermFreq(1)
            .minDocFreq(1))
            .actionGet();

I've made sure that document 1 and other documents in the index contain the word "chicago" in the text field, but it is always returning zero hits.

The 'text' field is indexed and has "term_vectors:true"

Am I missing something here?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: MLT using the Java API

Dan Tuffery
Thanks Vineeth.

I got it working in the end. I changed the implementation to use a MoreLikeThisQueryBuilder instead.

On Tuesday, June 4, 2013 2:37:35 AM UTC+1, Vineeth Mohan wrote:
How many documents are there in the index ?

Try
            .minTermFreq(0)
            .minDocFreq(0))

On Tue, Jun 4, 2013 at 1:58 AM, es newbie <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="Xz9yh2MvClUJ">dan.t...@...> wrote:
I'm trying to get the MLT feature working via the Java API, here is my request:

SearchResponse searchResponse = client.moreLikeThis(moreLikeThisRequest(index).type(type)
            .id(1)
             .fields("text")
            .minTermFreq(1)
            .minDocFreq(1))
            .actionGet();

I've made sure that document 1 and other documents in the index contain the word "chicago" in the text field, but it is always returning zero hits.

The 'text' field is indexed and has "term_vectors:true"

Am I missing something here?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="Xz9yh2MvClUJ">elasticsearc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: MLT using the Java API

Chang Zhang
Hello.

I've tried to use MoreLikeThisRequestBuilder with Java API and there was always no hit, the code as follows:

        MoreLikeThisRequestBuilder mlt = new MoreLikeThisRequestBuilder(client, "aaa", "bbb", "1");
         mlt.setField("title");
         SearchResponse response = client.moreLikeThis(mlt.request()).actionGet();

and I searches your solution, that is using MoreLikeThisQueryBuilder. but It doesn't work, either. My codes are:

        MoreLikeThisQueryBuilder query = QueryBuilders.moreLikeThisQuery(); 
        query.boost(1.0f).likeText("title").minTermFreq(10);

       SearchResponse searchResponse = client.prepareSearch("aaa").setTypes("bbb")
                .setQuery(query)
                .execute()
                .actionGet();

is there something wrong with the searchResponse part? could you give me some suggestions?
Thanks in advance!

Am Dienstag, 4. Juni 2013 10:34:15 UTC+2 schrieb es newbie:
Thanks Vineeth.

I got it working in the end. I changed the implementation to use a MoreLikeThisQueryBuilder instead.

On Tuesday, June 4, 2013 2:37:35 AM UTC+1, Vineeth Mohan wrote:
How many documents are there in the index ?

Try
            .minTermFreq(0)
            .minDocFreq(0))

On Tue, Jun 4, 2013 at 1:58 AM, es newbie <[hidden email]> wrote:
I'm trying to get the MLT feature working via the Java API, here is my request:

SearchResponse searchResponse = client.moreLikeThis(moreLikeThisRequest(index).type(type)
            .id(1)
             .fields("text")
            .minTermFreq(1)
            .minDocFreq(1))
            .actionGet();

I've made sure that document 1 and other documents in the index contain the word "chicago" in the text field, but it is always returning zero hits.

The 'text' field is indexed and has "term_vectors:true"

Am I missing something here?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: MLT using the Java API

Dan Tuffery
Hi, your request looks fine. 

The value in the 'text' parameter should be the actual text you want to use to find similar documents. You have min term frequency set to 10, which means there will only be a match if the term "title" appears in a  document at least 10 times. Also you haven't set the minDocFreq parameters so it defaults to 5, which means the term "title" must be present in at least 5 documents. Are you sure you have documents that have the term "title" in at least 10 times, and appears in at least 5 documents? Try decreasing the minTermFreq and minDocFreq parameter and experiment with the value in the text field.

I have found inquisitor very useful for testing queries:

https://github.com/polyfractal/elasticsearch-inquisitor

So in this case
On Monday, June 17, 2013 4:07:58 PM UTC+1, Chang Zhang wrote:
Hello.

I've tried to use MoreLikeThisRequestBuilder with Java API and there was always no hit, the code as follows:

        MoreLikeThisRequestBuilder mlt = new MoreLikeThisRequestBuilder(client, "aaa", "bbb", "1");
         mlt.setField("title");
         SearchResponse response = client.moreLikeThis(mlt.request()).actionGet();

and I searches your solution, that is using MoreLikeThisQueryBuilder. but It doesn't work, either. My codes are:

        MoreLikeThisQueryBuilder query = QueryBuilders.moreLikeThisQuery(); 
        query.boost(1.0f).likeText("title").minTermFreq(10);

       SearchResponse searchResponse = client.prepareSearch("aaa").setTypes("bbb")
                .setQuery(query)
                .execute()
                .actionGet();

is there something wrong with the searchResponse part? could you give me some suggestions?
Thanks in advance!

Am Dienstag, 4. Juni 2013 10:34:15 UTC+2 schrieb es newbie:
Thanks Vineeth.

I got it working in the end. I changed the implementation to use a MoreLikeThisQueryBuilder instead.

On Tuesday, June 4, 2013 2:37:35 AM UTC+1, Vineeth Mohan wrote:
How many documents are there in the index ?

Try
            .minTermFreq(0)
            .minDocFreq(0))

On Tue, Jun 4, 2013 at 1:58 AM, es newbie <[hidden email]> wrote:
I'm trying to get the MLT feature working via the Java API, here is my request:

SearchResponse searchResponse = client.moreLikeThis(moreLikeThisRequest(index).type(type)
            .id(1)
             .fields("text")
            .minTermFreq(1)
            .minDocFreq(1))
            .actionGet();

I've made sure that document 1 and other documents in the index contain the word "chicago" in the text field, but it is always returning zero hits.

The 'text' field is indexed and has "term_vectors:true"

Am I missing something here?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.