-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Closed
Labels
:Search/SearchSearch-related issues that do not fall into other categoriesSearch-related issues that do not fall into other categorieshigh hanging fruit
Description
For example, I have data:
PUT test
PUT test/battle/_mapping
{
"battle": {
"_parent": {
"type": "tank"
}
}
}
PUT test/tank/sherman
{"nation" : "usa"}
PUT test/tank/hellcat
{"nation" : "usa"}
PUT test/tank/panter
{"nation" : "germany"}
PUT test/battle/1?parent=sherman
PUT test/battle/2?parent=hellcat
PUT test/battle/3?parent=hellcat
PUT test/battle/4?parent=hellcat
PUT test/battle/5?parent=panter
PUT test/battle/6?parent=panter
{
"date": "15.02.2015",
"result": "win"
}So, I played 4 battles on American tanks and 2 on German tanks. I want to receive those data, when searching for battles. But I can do it only when I search for tanks:
GET test/tank/_search
{
"size": 0,
"aggs": {
"nation": {
"terms": {
"field": "nation"
},
"aggs": {
"battles_count": {
"children": {
"type": "battle"
}
}
}
}
}
}Although, I can make such a monster:
GET replays/battle/_search
{
"size": 0,
"aggs": {
"usa": {
"filter": {
"has_parent": {
"parent_type": "tank",
"query": {
"term": {
"nation": "usa"
}
}
}
},
"aggs": {
"count": {
"value_count": {
"field": "_id"
}
}
}
},
"germany": {
"filter": {
"has_parent": {
"parent_type": "tank",
"query": {
"term": {
"nation": "germany"
}
}
}
},
"aggs": {
"count": {
"value_count": {
"field": "_id"
}
}
}
}
}
}But it's VERY uncomfortable and I must know all the terms of nation field. So, I'm asking for some kind of parent aggregation.
apyankov, zt2, liangqing, willfill, tyre and 7 more
Metadata
Metadata
Assignees
Labels
:Search/SearchSearch-related issues that do not fall into other categoriesSearch-related issues that do not fall into other categorieshigh hanging fruit