Ответ 1
Вам нужно иметь незакрашенные копии терминов в индексе, в вашем сопоставлении используйте несколько полей:
{
"test": {
"mappings": {
"book": {
"properties": {
"author": {
"type": "string",
"fields": {
"untouched": {
"type": "string",
"index": "not_analyzed"
}
}
},
"title": {
"type": "string",
"fields": {
"untouched": {
"type": "string",
"index": "not_analyzed"
}
}
},
"docType": {
"type": "string",
"fields": {
"untouched": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
}
}
В вашей задаче запроса на агрегирование неокенизированные поля:
"aggs" : {
"author" : {
"terms" : {
"field" : "author.untouched",
"size": 20,
"order" : { "_term" : "asc" }
}
},
"title" : {
"terms" : {
"field" : "title.untouched",
"size": 20
}
},
"contentType" : {
"terms" : {
"field" : "docType.untouched",
"size": 20
}
}
}