【发布时间】:2018-07-22 01:52:42
【问题描述】:
我有以下 ElasticSearch 映射。 映射:
"cid": {
"type": "long"
},
"crankings": {
"type": "nested",
"properties": {
"rank": {
"type": "long"
},
"name": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
我正在尝试对嵌套字段 (crankings.rank.raw) 和 cid 上的基数进行聚合。
我正在形成以下聚合查询。 查询:
{
"size": 0,
"aggregations": {
"crankings": {
"nested": {
"path": "crankings"
},
"aggregations": {
"crankings": {
"terms": {
"field": "crankings.name.raw",
"size": 0
},
"aggregations": {
"cid": {
"cardinality": {
"field": "cid"
}
}
}
}
}
}
}
}
但在结果中,我没有得到预期的输出。
结果:
"buckets": [
{
"key": "xxxxxxxx",
"doc_count": 3223,
"cid": {
"value": 0
}
},
{
"key": "yyyyyy",
"doc_count": 1212,
"cid": {
"value": 0
}
},
....
我得到 cid = 0,这是意料之外的。
让我知道如何对查询进行建模以获得预期结果。 ElasticSearch 2.1.1 版
【问题讨论】:
标签: java elasticsearch aggregation