user379151
user379151

Reputation: 1379

Removing duplicates in Elasticsearch cross cluster search

I'm using cross cluster search and searching for a document by _id that exists in both clusters. ES returns with 2 hits (1 in local index, 1 in remote index). I just want the one in the local index. How can I remove the duplicate from the remote cluster ?

Query :

{
"query": {
"terms": {
"_id": [ "123"]
}
}
}```

Upvotes: 0

Views: 449

Answers (1)

Daniel Schneiter
Daniel Schneiter

Reputation: 1996

You should be able achieving this by using Field Collapsingover the _id-field and define a sorting condition in which documents from your local cluster rank higher (e.g a cluster id, or a timestamp etc)

(see Elasticsearch Reference: Field Collapsing)

Upvotes: 1

Related Questions