У меня ниже структура документа.
{"tagsData": [
{
"hashtag": "computer",
"displayName": "Computer",
"urlKeyword": "computer"
},
{
"hashtag": "artificialIntelligence",
"displayName": "Artificial Intelligence",
"urlKeyword": "artificial-intelligence"
}
]}
Мое требование - применить агрегацию к полю хэштега и получить результат, как показано ниже
{"aggregations": {
"tags": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "computer",
"displayName": "Computer",
"urlKeyword": "computer"
"doc_count": 1
},
{
"key": "artificialIntelligence",
"displayName": "Artificial Intelligence",
"urlKeyword": "artificial-intelligence"
"doc_count": 1
}]}
}}
Elasticsearch версия 5.3 Пожалуйста, дайте мне знатькак я могу этого достичь?Каким должно быть сопоставление и запрос?
РЕДАКТИРОВАТЬ
Сопоставление, которое я пытаюсь.
{
"test": {
"properties" : {
"tagsData" : {
"type" : "object",
"properties": {
"hashtag" : {"type": "keyword", "index": "not_analyzed"},
"displayName" : {"type": "keyword", "index": "not_analyzed"},
"urlKeyword" : {"type": "keyword", "index": "not_analyzed"}
}
}
}
}
}