Cross Cluster Search - Searching equal number of documents from 2 or more clusters

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):

Opensearch - 2.5

Describe the issue:

I have couple of clusters connected, each of different domain. Is there a way to get results from both the clusters instead of getting results from single cluster based on the search term?

To expand,

  1. I will be using search templates with different queries in each of these clusters.
  2. When I search for a common term in both the clusters, based on the relevance score, the results are either from a remote cluster or local cluster.

But, I would like to get equal number of results say 10 or 20 based on the size from both the clusters.

PS: I tried msearch and it seems to work, but wondering if the same can be achieved through search api.



Relevant Logs or Screenshots:

You can use collapse. Basically, you’ll need some field in each document that shows the cluster name, and collapse on it. _index might work too, if you have different index names, one per cluster.

If you specify in inner_hits the desired size (e.g. 10 or 20) you should get what you want.

However, it’s likely going to be more expensive than your msearch :slight_smile:

Thanks @radu.gheorghe . I didn’t realise we could use collapse. I will give it a try.

1 Like