У меня есть одно поле: name.keyword. Мне бы хотелось, чтобы результаты агрегации (или их набора в иерархической разбивке) выглядели следующим образом:
all_names - a count of all distinct values for the name.keyword field
names_a_through_e - a count of all distinct values that are limited to those values that start with "A" through those that start with "E"
names_a - a count of all distinct values that are limited to those that start with "A"
names - a list of each of these names and their count
names_b - a count of all distinct values that are limited to those that start with "B"
names - a list of each of these names and their count
...
names_f_through_j - a count of all distinct values that are limited to those values that start with "F" through those that start with "J"
names_f - a count of all distinct values that are limited to those that start with "F"
names - a list of each of these names and their count
names_g - a count of all distinct values that are limited to those that start with "G"
names - a list of each of these names and their count
...
...
Я, безусловно, могу охватить самые внутренние списки, например:
"a_names": {
"terms": {
"field": "name.keyword",
"include": "A.*",
"size": 100,
"order": {"_term": "asc"}
}
}
Но это не дает мне счет на этом уровне - сумму всех документов с A * в поле name.keyword.
Или есть способ сделать это структурированное ведение на одно поле, которое будет хорошо организовывать макет, как я описал?