我有一个具有以下映射的索引:
a=00090
printf -v a %.0f $a
echo $a
90
总而言之,adID字段的映射为
{"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}
结果是
: agg = {
...: "aggs" : {
...: "type_count" : {
...: "cardinality" : {
...: "field" : "message.context.keyword.adID"
...: }
...: }
...: }
...: }
为什么基数聚合的结果为零?
答案 0 :(得分:2)
您在查询中使用字段引用的顺序错误
{
"aggs" : {
"type_count" : {
"cardinality" : {
"field" : "message.context.adID.keyword"
}
}
}
}