More Like This with range


(Matthew Terenzio) #1

So I'd like to do a MLT query combined with a Range but I'd rather it be
based on the ID of a document rather than the text. It looks to me Range is
only available from the Query DSL but not within an MLT API call?

I could, of course, retrieve the document and use the text but fiigured I
was missing something. I see that the Search API is available from within
the MLT API but don't see Range in there.

Thanks.


(Shay Banon) #2

You are not missing something :), use GET to fetch the doc, and build the
search request yourself with the relevant text in the MLT query.

On Wed, Oct 26, 2011 at 5:10 PM, Matthew Terenzio mterenzio@gmail.comwrote:

So I'd like to do a MLT query combined with a Range but I'd rather it be
based on the ID of a document rather than the text. It looks to me Range is
only available from the Query DSL but not within an MLT API call?

I could, of course, retrieve the document and use the text but fiigured I
was missing something. I see that the Search API is available from within
the MLT API but don't see Range in there.

Thanks.


(Matthew Terenzio) #3

It actually looks like I was able to accomplish it with only one request by
using the More Like This API and including a filter in the body with a
range, like this:

curl -XGET 'http://localhost:9200/news/articles/[id]/_mlt?' -d '{"filter" :
{"range" : {"timestamp" : {"gt" : "1319575346"}}} }'

On Wed, Oct 26, 2011 at 4:40 PM, Shay Banon kimchy@gmail.com wrote:

You are not missing something :), use GET to fetch the doc, and build the
search request yourself with the relevant text in the MLT query.

On Wed, Oct 26, 2011 at 5:10 PM, Matthew Terenzio mterenzio@gmail.comwrote:

So I'd like to do a MLT query combined with a Range but I'd rather it be
based on the ID of a document rather than the text. It looks to me Range is
only available from the Query DSL but not within an MLT API call?

I could, of course, retrieve the document and use the text but fiigured I
was missing something. I see that the Search API is available from within
the MLT API but don't see Range in there.

Thanks.


(Shay Banon) #4

Ha!, yea, a "filter" will work, though a "query" will not (since the query
is what is automatically built my the mlt API).

On Thu, Oct 27, 2011 at 2:25 AM, Matthew Terenzio mterenzio@gmail.comwrote:

It actually looks like I was able to accomplish it with only one request by
using the More Like This API and including a filter in the body with a
range, like this:

curl -XGET 'http://localhost:9200/news/articles/[id]/_mlt?' -d '{"filter"
: {"range" : {"timestamp" : {"gt" : "1319575346"}}} }'

On Wed, Oct 26, 2011 at 4:40 PM, Shay Banon kimchy@gmail.com wrote:

You are not missing something :), use GET to fetch the doc, and build the
search request yourself with the relevant text in the MLT query.

On Wed, Oct 26, 2011 at 5:10 PM, Matthew Terenzio mterenzio@gmail.comwrote:

So I'd like to do a MLT query combined with a Range but I'd rather it be
based on the ID of a document rather than the text. It looks to me Range is
only available from the Query DSL but not within an MLT API call?

I could, of course, retrieve the document and use the text but fiigured I
was missing something. I see that the Search API is available from within
the MLT API but don't see Range in there.

Thanks.


(system) #5