Please help me find a mechanism for aggregating by the following domain or to prove that it does not exist in the current API.
curl -XDELETE 127.0.0.1:9200/test_index curl -XPUT 127.0.0.1:9200/test_index -d '{ "mappings": { "contact": { "properties": { "facebook_profile": { "type": "nested", "properties": { "education": { "type": "string" }, "year": { "type": "integer" } } }, "google_profile": { "type": "nested", "properties": { "education": { "type": "string" }, "year": { "type": "integer" } } } } } } }' curl -XPUT 127.0.0.1:9200/test_index/contact/contact1 -d '{ "google_profile": { "education": "stanford", "year": 1990 } }' curl -XPUT 127.0.0.1:9200/test_index/contact/contact2 -d ' { "facebook_profile": { "education": "stanford", "year": 1990 } }'
How can I query ES to find statistics on how many contacts graduated from individual universities?
I found one opportunity, but it does not give me the desired result, because it cannot answer the question above regarding contacts, but only on their specific profiles (attached documents):
curl -XPOST '127.0.0.1:9200/test_index/_search?search_type=count&pretty=true' -d '{ "aggs": { "facebook_educations": { "aggs": { "field": { "terms": { "field": "contact.facebook_profile.education" }, "aggs": { "reverse": { "reverse_nested": { } } } } }, "nested": { "path": "contact.facebook_profile" } }, "google_educations": { "aggs": { "field": { "terms": { "field": "contact.google_profile.education" }, "aggs": { "reverse": { "reverse_nested": { } } } } }, "nested": { "path": "contact.google_profile" } } } }'
What gives me:
"aggregations" : { "facebook_educations" : { "doc_count" : 1, "field" : { "doc_count_error_upper_bound" : 0, "sum_other_doc_count" : 0, "buckets" : [ { "key" : "stanford", "doc_count" : 1, "reverse" : { "doc_count" : 1 } } ] } }, "google_educations" : { "doc_count" : 1, "field" : { "doc_count_error_upper_bound" : 0, "sum_other_doc_count" : 0, "buckets" : [ { "key" : "stanford", "doc_count" : 1, "reverse" : { "doc_count" : 1 } } ] } } }
But here I canโt be sure that if the contact found is the same or a different document (parent), respectively, I can not answer my initial question.
Thanks for any advice.