Remove duplicate documents from a search in Elasticsearch

You could use field collapsing, group the results on the name field and set the size of the top_hits aggregator to 1. /POST http://localhost:9200/test/dedup/_search?search_type=count&pretty=true { “aggs”:{ “dedup” : { “terms”:{ “field”: “name” }, “aggs”:{ “dedup_docs”:{ “top_hits”:{ “size”:1 } } } } } } this returns: { “took” : 192, “timed_out” : false, “_shards” : { … Read more