Суммарная агрегация Elasticsearch возвращает ноль - PullRequest
0 голосов
/ 02 марта 2019

У меня есть индекс со следующим отображением:

{"vahid":{"mappings":{"doc":{"properties":{"@timestamp":{"type":"date"},"@version":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"message":{"properties":{"context":{"properties":{"adID":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"fID":{"type":"long"},"zoneID":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}}}},"filename":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"funcName":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"hostname":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"lineno":{"type":"long"},"logLevel":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"message":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"pid":{"type":"long"},"timestamp":{"type":"float"}}}}}}}}

в итоге, отображение для поля adID равно

{"adID":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}

, и я хочу выполнить агрегирование кардинальности для подсчетачисло уникальных идентификаторов adID

: agg = { 
...:     "aggs" : { 
...:         "type_count" : { 
...:             "cardinality" : { 
...:                 "field" : "message.context.keyword.adID" 
...:             } 
...:         } 
...:     } 
...: }  

и результат равен

{'took': 13,
 'timed_out': False,
 '_shards': {'total': 5, 'successful': 5, 'skipped': 0, 'failed': 0},
 'hits': {'total': 7,
  'max_score': 1.0,
  'hits': [{'_index': 'vahid',
    '_type': 'doc',
    '_id': '0XrVPWkBu4YGVBHQV9Sa',
    '_score': 1.0,
    '_source': {'message': {'context': {'adID': 1}}}},
   {'_index': 'vahid',
    '_type': 'doc',
    '_id': '0nrWPWkBu4YGVBHQO9TR',
    '_score': 1.0,
    '_source': {'message': {'context': {'fID': 1}}}},
   {'_index': 'vahid',
    '_type': 'doc',
    '_id': '03rXPWkBu4YGVBHQKdQt',
    '_score': 1.0,
    '_source': {'message': {'context': {'adID': 2}}}},
   {'_index': 'vahid',
    '_type': 'doc',
    '_id': '13rXPWkBu4YGVBHQ2NQG',
    '_score': 1.0,
    '_source': {'message': {'context': {'adID': 3}}}},
   {'_index': 'vahid',
    '_type': 'doc',
    '_id': '1XrXPWkBu4YGVBHQzdQG',
    '_score': 1.0,
    '_source': {'message': {'context': {'adID': 3}}}},
   {'_index': 'vahid',
    '_type': 'doc',
    '_id': '1nrXPWkBu4YGVBHQ09Qb',
    '_score': 1.0,
    '_source': {'message': {'context': {'adID': 3}}}},
   {'_index': 'vahid',
    '_type': 'doc',
    '_id': '1HrXPWkBu4YGVBHQbdRa',
    '_score': 1.0,
    '_source': {'message': {'context': {'adID': 3}}}}]},
 'aggregations': {'type_count': {'value': 0}}}

Почему результат агрегирования мощности равен нулю?

1 Ответ

0 голосов
/ 02 марта 2019

В запросе вы указали неправильную ссылку на поле

{ 
     "aggs" : { 
         "type_count" : { 
            "cardinality" : { 
                "field" : "message.context.adID.keyword" 
            } 
        } 
    }   
}  
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...