json - Aggregating array of values in elasticsearch -
I need to collect an array as follows
Two document examples:
city array to know allcitytotravelerCode "has gone in: I want something like this:{" passenger ": {" name ":" patrick "}," cities ": {" sapolo ": 2, "Total": 3}}Where
totalcitiesis the length of the array zero, II "Droodgeeniro": 2, "Curitiba": "Total" Accumulation of words and try yoga Minister, but could not output the desired output.Document structure can be changed, so if something like this will help me, I would be happy to know " Cities were posted above In the document,
"There is a Jason array, it is a Jason object if there is a possibility to change the document structure Then I will replace cities in the form of an array of objects in the document
Example document:
Everybody: [{"name": "sopolo" "visit_count": "2",}, {"name": "prevention hero" "visit_ count": "1",}] Cities need to be typed in index mapping
"mappings": {"& lt; type_name & gt;": {"Properties": {"cities": {"type" {"Type": "string"}, "count": {"type": "integer"}, "value": {"type": "long"} "nested", "property": {"city" : {"Type": "string"}}}, "date": {"type": "date", "for" type ":" string "}," passenger ": {" type ":" string "}}}} After which you can use to count the city per user. The query will appear on these lines: {"}": {"city_travelled": {"nested": {"path": {"}" {"traveler": "patrick"}}, "aggregation" : "City"}, "ags": {"citycount": {"cardinality": {"field": "cities. Whistle"}}}}}}
Comments
Post a Comment