How to find the distinct values in a nested type field in elasticsearch? Can anyone provide one example?

I am looking for one example on how to extract distinct values of a nested type property in elastic search. Could anyone provide an example?

I have a below query where I am trying to retrieve distinct values of "batchId" from nested type "admin" as follows:

{
	"aggs" : {
		"groupBatches" : {
			"nested": {
                "path": "admin"
			},
			"aggs" : {
				"batches" : {
					"terms" : {"field" : "admin.ids.batchId"} 
				}
			}
		}
	}
}

If what I am trying is wrong, Please provide some example for better understanding.

@dadoonet
Hi David,
Could you please take a look?

thank you.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.