I have a number of documents indexed in OpenSearch. I've been told it is possible to have a "related documents" search, where I can find documents similar to one with an ID of X, but haven't been able to locate any examples or documentation for it.
Is it possible to take a document ID and then find N number of documents that are similar to it? Any examples or documentation you can point me to using the Java client would be very helpful!
Yes, you can do it with a
more_like_this
query and as it's not really explained in the OpenSearch documentation, you can refer to the Elasticsearch one on themore_like_this
query.It goes as shown below where you can search
my-index
for documents that are similar to another specific document with ID 1 frommy-other-index
:like
is an array where you can specify as many documents as you want and also free text.Regarding doing this with the OpenSearch Java client, it should go something like this: