Maybe someone will find it useful.
Finally I've found solution, -- reverse_nested
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html
aggregation (new in 1.2.0) is what I was needed. Here is my example solved.
curl -XPOST "http://localhost:9200/emotions/emotion/_search?pretty=true" -d
'{
"aggregations": {
"emotionAggr": {
"nested": {
"path": "companyEmotions"
},
"aggregations": {
"emotionAggr2": {
"filter": {
"term": {"companyEmotions.company": "foo"}
},
"aggregations": {
"emotionAggr3": {
"terms": {
"field": "companyEmotions.emotion"
},
"aggregations": {
"emotionAggr4": {
"reverse_nested": {
},
"aggregations": {
"emotionAggr5": {
"sum": {"script":
"doc["count"].value + 1"}
}
}
}
}
}
}
}
}
}
}
}'
Thanks, Viacheslav.
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/48dc4748-e72f-4781-9c83-fb9afd356957%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.