# More Like This with range

**URL:** <https://discuss.elastic.co/t/more-like-this-with-range/5694>\
**Category:** Elasticsearch\
**Created:** [October 26, 2011, 3:10pm UTC](https://discuss.elastic.co/t/more-like-this-with-range/5694 "2011-10-26T15:10:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthew\_Terenzio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matthew_terenzio/32/2807_2.png) [@Matthew\_Terenzio](https://discuss.elastic.co/u/Matthew_Terenzio)\
**Post date:** [October 26, 2011, 3:10pm UTC](https://discuss.elastic.co/t/more-like-this-with-range/5694/1 "2011-10-26T15:10:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [October 26, 2011, 8:40pm UTC](https://discuss.elastic.co/t/more-like-this-with-range/5694/2 "2011-10-26T20:40:09Z")

</div>

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.com](mailto:mterenzio@gmail.com)wrote:

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

---

<div class="post-metadata">

**Author:** ![Matthew\_Terenzio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matthew_terenzio/32/2807_2.png) [@Matthew\_Terenzio](https://discuss.elastic.co/u/Matthew_Terenzio)\
**Post date:** [October 27, 2011, 12:25am UTC](https://discuss.elastic.co/t/more-like-this-with-range/5694/3 "2011-10-27T00:25:19Z")

</div>

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?](http://localhost:9200/news/articles/%5Bid%5D/_mlt?)' -d '{"filter" :  
{"range" : {"timestamp" : {"gt" : "1319575346"}}} }'

On Wed, Oct 26, 2011 at 4:40 PM, Shay Banon [kimchy@gmail.com](mailto: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.com](mailto:mterenzio@gmail.com)wrote:
> 
> > 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.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [October 27, 2011, 7:10pm UTC](https://discuss.elastic.co/t/more-like-this-with-range/5694/4 "2011-10-27T19:10:37Z")

</div>

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.com](mailto:mterenzio@gmail.com)wrote:

> 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?](http://localhost:9200/news/articles/%5Bid%5D/_mlt?)' -d '{"filter"  
> : {"range" : {"timestamp" : {"gt" : "1319575346"}}} }'
> 
> On Wed, Oct 26, 2011 at 4:40 PM, Shay Banon [kimchy@gmail.com](mailto: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.com](mailto:mterenzio@gmail.com)wrote:
> > 
> > > 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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:50am UTC](https://discuss.elastic.co/t/more-like-this-with-range/5694/5 "2017-07-06T03:50:36Z")

</div>


