[英]How to aggregate data with filter on text fields in elasticsearch?
Having read all the tutorials on ES website, I cannot achieve my goal. 阅读了ES网站上的所有教程之后,我无法实现自己的目标。 We are using ES 1.7.6 and I want to have only one single instance of documents matching my criteria. 我们正在使用ES 1.7.6,并且我只希望有一个符合我标准的文档实例。 But what I get from ES is all the data matching the filter and the aggregation statistics. 但是我从ES中得到的是与过滤器和聚合统计信息匹配的所有数据。
GET _search
{
"size":1000,
"query":{
"bool":{
"should":[
{
"match":{
"isoMessage.fields.39":{
"query":"00"
}
}
}
]
}
},
"aggs":{
"group_by_CATI":{
"terms":{
"field":"isoMessage.fields.41"
}
}
}
}
Note that the index of isoMessage.fields.41
is set to not_analyzed
. 请注意, isoMessage.fields.41
的索引设置为not_analyzed
。 Thanks for any help; 谢谢你的帮助;
UPDATE: The mapping 更新:映射
{
"cm": {
"mappings": {
"Event": {
"properties": {
"deleted": {
"type": "boolean"
},
"id": {
"type": "string"
},
"isoMessage": {
"properties": {
"fields": {
"properties": {
"2": {
"type": "string"
},
"3": {
"type": "string"
},
"4": {
"type": "string"
},
"7": {
"type": "string"
},
"11": {
"type": "string"
},
"12": {
"type": "string"
},
"13": {
"type": "string"
},
"14": {
"type": "string"
},
"22": {
"type": "string"
},
"25": {
"type": "string"
},
"32": {
"type": "string"
},
"37": {
"type": "string"
},
"39": {
"type": "string"
},
"41": {
"type": "string"
},
"42": {
"type": "string"
},
"48": {
"type": "string"
},
"49": {
"type": "string"
},
"60": {
"type": "string"
},
"63": {
"type": "string"
},
"100": {
"type": "string"
},
"128": {
"type": "string"
}
}
},
"isReversal": {
"type": "boolean"
},
"isReversalDone": {
"type": "boolean"
},
"messageSpec": {
"type": "string"
},
"mti": {
"type": "string"
},
"request": {
"type": "boolean"
},
"response": {
"type": "boolean"
}
}
},
"msg": {
"type": "string"
},
"occurDate": {
"type": "long"
},
"receiver": {
"type": "string"
},
"rrn": {
"type": "string"
},
"sender": {
"type": "string",
"index": "not_analyzed"
},
"txId": {
"type": "string"
},
"version": {
"type": "long"
}
}
}
}
}
}
If I understand correctly, and you want to get only the aggregation result: 如果我理解正确,而您只想获得汇总结果:
Change your size
field from: 从以下位置更改size
字段:
"size":1000
to 至
"size":0
in order to set the _search
query displayed results limit. 为了设置_search
查询显示结果的限制。 It won't affect the aggregation result, though. 但是,它不会影响聚合结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.