2
我需要做一個查詢,以聚合方式列出整個對象。映射是這樣的:Elasticsearch - Lsit整個對象聚合
{
"travelers": {
"properties": {
"traveler": "string",
"cars": {
"type":"nested",
"properties": {
"type": {
"type":"string"
},
"color": {
"type":"string"
}
}
}
}
}
}
和查詢我可以是這樣的:
{
"aggregations": {
"people": {
"terms": {
"field":"traveler"
}
},
"aggregations": {
"cars": {
"nested": {
"path":"cars"
},
"aggregations": {
"types": {
"terms": {
"field":"cars.type"
}
}
}
}
}
}
}
但此查詢只返回類型的汽車。我可以修改它來返回類型和顏色,但是我不能那樣告訴哪種顏色與哪種類型的汽車有關。我怎樣才能做到這一點?