curl -X PUT localhost:9200/test -s -H 'Content-Type: application/json' -d'{ "settings" : { "number_of_shards" : 1 }, "mappings" : { "objects" : { "properties" : { "name" : { "fields": { "_raw":{ "type":"keyword" } }, "type" : "text" }, "timestamp": { "type": "date" }, "some":{ "type":"integer" } } } } }' for i in $(seq 10010); do curl -X POST localhost:9200/test/objects -s -H 'Content-Type: application/json' -d@- < 2" } } } } } }' curl localhost:9200/test/objects/_search?pretty=true -s -H 'Content-Type: application/json' -d' { "size" : 0, "aggs" : { "my_buckets": { "composite" : { "sources" : [ { "duplicate": { "terms" : { "field": "name._raw" } } } ], "after": { "duplicate": "John Doe #10" } }, "aggs": { "filter": { "bucket_selector": { "buckets_path": { "doc_count": "_count" }, "script": "params.doc_count > 2" } } } } } }' curl -X DELETE localhost:9200/test