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

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

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.

Thanks - could you tell me more about this option?

In the documentation there is an example where it is possible to use a document, they call it an artificial document.

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

1 Like

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