ES语句:{ "query": { "bool": { "should": [ { "match": { "erpSupplierFlowId": "1001E111230001IPJP6W" } }, { "match": { "erpSupplierFlowId": "1001A110000001CBWJ0I" } }, { "match": { "erpSupplierFlowId": "1001A110000001IPM06S" } }, { "match": { "companyCode": "10101" } } ] } }, //设置为0代表只需要聚合的结果 "size": 0, "track_total_hits": false, "aggs": { "my_buckets": { "composite": { //存上一个位置游标,查找下一页,如果往前翻页,前端给after,每次翻页,前端存一个after数组,下标对应页数 // "after": { // "erpGoodsId": "P100009", // "batchNum": "2201055103" // }, "size": 1000, "sources": [ { "erpGoodsId": { "terms": { "field": "erpGoodsId", "order": "asc" } } }, { "batchNum": { "terms": { "field": "batchNum", "order": "asc" } } }, { "wmsProductCode": { "terms": { "field": "wmsProductCode", "missing": "null", "order": "asc" } } } ] }, "aggs": { "filter_empty_dest": { "bucket_selector": { "buckets_path": { "count": "_count" }, "script": "params.count != null" } } } } } }
时间: 2023-07-12 13:02:25 浏览: 43
这是一个 Elasticsearch 查询语句,具体含义如下:
- 查询条件:`erpSupplierFlowId` 字段等于 "1001E111230001IPJP6W" 或 "1001A110000001CBWJ0I" 或 "1001A110000001IPM06S",同时 `companyCode` 字段等于 "10101"。
- `size` 设为 0,表示只需要聚合的结果。
- `track_total_hits` 设为 false,表示不需要返回总命中数。
- 聚合语句:使用 `composite` 聚合,按 `erpGoodsId`、`batchNum` 和 `wmsProductCode` 三个字段分组聚合,每组最多包含 1000 条记录。
- 在聚合结果中过滤掉空的 `dest` 分组。
这个查询语句的作用是,根据指定的查询条件和分组字段,对匹配的文档进行聚合统计,并返回结果。
相关问题
es _search { "query": { "match": { "contentType": "msword" } } }全文匹配
你提供的是一个 Elasticsearch 的查询语句,其中 "match" 查询是进行全文匹配的一种方式,它可以匹配指定字段中包含有查询字符串的文档。
在这个查询语句中,我们指定了要匹配 "contentType" 字段中包含 "msword" 的文档。如果你想要对更多字段进行全文匹配,可以通过指定多个 "match" 查询来实现。例如:
```
{
"query": {
"bool": {
"should": [
{ "match": { "title": "elasticsearch" } },
{ "match": { "content": "elasticsearch" } }
]
}
}
}
```
这个查询语句会匹配 "title" 或者 "content" 字段中包含 "elasticsearch" 的文档。
ES语句如下:{ "query": { "bool": { "should": [ { "match": { "erpSupplierFlowId": "1001E111230001IPJP6W" } }, { "match": { "erpSupplierFlowId": "1001A110000001CBWJ0I" } } ] } }, //设置为0代表只需要聚合的结果 "size": 0, "track_total_hits": false, "aggs": { "my_buckets": { "composite": { //存上一个位置游标,查找下一页,如果往前翻页,前端给after,每次翻页,前端存一个after数组,下标对应页数 // "after": { // "erpGoodsId": "P100009", // "batchNum": "2201055103" // }, "size": 10, "sources": [ { "erpGoodsId": { "terms": { "field": "erpGoodsId", "order": "asc" } } }, { "batchNum": { "terms": { "field": "batchNum", "order": "asc" } } }, { "wmsProductCode": { "terms": { "field": "wmsProductCode", "missing": "null", "order": "asc" } } } ] }, "aggs": { "filter_empty_dest": { "bucket_selector": { "buckets_path": { "count": "_count" }, "script": "params.count != null" } } } } } }
这是一个Elasticsearch查询语句,作用是聚合查询指定的两个"erpSupplierFlowId"值,并按照"erpGoodsId"、"batchNum"、"wmsProductCode"三个字段进行分组聚合,每组聚合结果的数量不超过10个。
具体的实现方式是使用布尔查询进行两个"erpSupplierFlowId"的匹配,然后使用复合聚合(composite aggregation)对分组字段进行聚合。在聚合的结果中,使用"bucket_selector"过滤掉聚合结果数量为0的分组。最后返回的结果中不包含实际文档,只有聚合分组的信息。