Cardinality on Objects

How can I do a cardinality aggregation to count objects? I tried below and it does not work when trying to count the number of distinct addresses in my index. However, if I change employee.address.* to employee.address.city I get the expected results, but just for the city field. Any help would be appreciated. Thanks.

Kevin

{
	"size": 0,
			"aggs": {
				"employee_address": {
					"cardinality": {
						"field": "employee.address.*"
					}
				},
				"positions": {
					"cardinality": {
						"field": "position"
					}
				}
			}
}

Could you copy all these values to a single field at index-time and then run the cardinality aggregation on that field?

Thanks for the suggestion. We have a ton of records that are already processed and indexed and we would have to redo all that in order to change the mapping and I am hoping to avoid that. Hopefully someone has a suggestion of how to do this with the mapping as it is. I wonder if objects are not supported by the cardinality aggregation in general? That is, you can't count the number of distinct objects, just their attributes....

This is not supported.

Roger that.....I will redo the processing/mapping of the data if this becomes a pressing requirement. Thanks.

Kevin

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