Вы можете начать с нескольких необработанных terms
агрегатов и вернуться к NEST DSL :
POST complexities/_doc
{
"complexProperty1": {
"A": "example",
"B": "1",
"D": true,
"E": "case",
"F": [
"guide1",
"guide2"
]
},
"complexProperty2": {
"X": "10",
"Y": [
"specimen1",
"specimen2"
],
"Z": "blueprint"
}
}
GET complexities/_search
{
"size": 0,
"aggs": {
"by_A": {
"terms": {
"field": "complexProperty1.A.keyword"
},
"aggs": {
"by_D": {
"terms": {
"field": "complexProperty1.D"
}
},
"by_E": {
"terms": {
"field": "complexProperty1.E.keyword"
}
}
}
}
}
}
Чтобы получить базовые документы, вы можете добавить агг top_hits
к каждой субагг, вкл. верхний уровень:
{
"size": 0,
"aggs": {
"by_A": {
"terms": {
"field": "complexProperty1.A.keyword"
},
"aggs": {
"top_hits_only": {
"top_hits": {
"_source": "*"
}
},
"by_D": {
"terms": {
"field": "complexProperty1.D"
},
"aggs": {
"top_hits_only": {
"top_hits": {
"_source": "*"
}
}
}
},
"by_E": {
"terms": {
"field": "complexProperty1.E.keyword"
},
"aggs": {
"top_hits_only": {
"top_hits": {
"_source": "*"
}
}
}
}
}
}
}
}