Cardinality on Objects


(Kevin M.) #1

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"
					}
				}
			}
}

(Adrien Grand) #2

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


(Kevin M.) #3

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....


(Adrien Grand) #4

This is not supported.


(Kevin M.) #5

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

Kevin


(system) #6

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