# More like this query using an existing document, but I don't know its ID

**URL:** <https://discuss.elastic.co/t/more-like-this-query-using-an-existing-document-but-i-dont-know-its-id/309843>\
**Category:** Elasticsearch\
**Created:** [July 18, 2022, 5:26am UTC](https://discuss.elastic.co/t/more-like-this-query-using-an-existing-document-but-i-dont-know-its-id/309843 "2022-07-18T05:26:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![catmanjan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/catmanjan/32/77810_2.png) [@catmanjan](https://discuss.elastic.co/u/catmanjan)\
**Post date:** [July 18, 2022, 5:26am UTC](https://discuss.elastic.co/t/more-like-this-query-using-an-existing-document-but-i-dont-know-its-id/309843/1 "2022-07-18T05:26:45Z")

</div>

I want to do a more like this query to return similar documents to a document that already exists in my index.

I don't know the documents ID ahead of time, but I do know a term value that I can use to look it up (also, it may or may not exist)

Is there a way to avoid having to do 2 requests? E.g. more like this where term = value, rather than find term = value, extract ID, pass to more like this

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [July 18, 2022, 12:35pm UTC](https://discuss.elastic.co/t/more-like-this-query-using-an-existing-document-but-i-dont-know-its-id/309843/2 "2022-07-18T12:35:20Z")

</div>

Hi @catmanjan .

I think you will need to run a query to fetch the id, I also did something similar using MLT and as I wanted to use the id of the document I had to make another query to fetch the id.  
The other option is to "like" a document instead of the id.

Anyway, let's wait to see if anyone has another option.

---

<div class="post-metadata">

**Author:** ![catmanjan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/catmanjan/32/77810_2.png) [@catmanjan](https://discuss.elastic.co/u/catmanjan)\
**Post date:** [July 19, 2022, 12:03am UTC](https://discuss.elastic.co/t/more-like-this-query-using-an-existing-document-but-i-dont-know-its-id/309843/3 "2022-07-19T00:03:12Z")

</div>

> [@RabBit\_BR](#):
>
> The other option is to "like" a document instead of the id.

Thanks - could you tell me more about this option?

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [July 19, 2022, 3:10am UTC](https://discuss.elastic.co/t/more-like-this-query-using-an-existing-document-but-i-dont-know-its-id/309843/4 "2022-07-19T03:10:29Z")

</div>

In the [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-mlt-query.html#_document_input_parameters) there is an example where it is possible to use a document, they call it an artificial document.

---

<div class="post-metadata">

**Author:** ![catmanjan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/catmanjan/32/77810_2.png) [@catmanjan](https://discuss.elastic.co/u/catmanjan)\
**Post date:** [July 19, 2022, 5:29am UTC](https://discuss.elastic.co/t/more-like-this-query-using-an-existing-document-but-i-dont-know-its-id/309843/5 "2022-07-19T05:29:39Z")

</div>

Thanks that doesn't quite do what I need, I've gone with the 2 query approach for now, it would be nice for Elastic to support it as a single query

---

<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:** [August 16, 2022, 5:30am UTC](https://discuss.elastic.co/t/more-like-this-query-using-an-existing-document-but-i-dont-know-its-id/309843/6 "2022-08-16T05:30:24Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
