我是 flex 搜索的新鲜蜂,我正尝试通过聚合从 flex 搜索中查询文档。查询如下所示: { "size": 25000, "query": { "filtered": { "query": { "bool": { "must_not": { "term": { "vlanId": [ 2, 4, 8, 12, 16, 28, 0, 20, 24, 44, 544 ] } } } }, "filter": { "bool": { "must": { "exists": { "field": "ipv4" } } } } } }, "aggregations": { "vlan_ids": { "terms": { "field": "vlanId" }, "aggregations": { "top": { "top_hits": { "from": 0, "size": 10, "explain": true } } } } } }
执行后,我收到了Failed to execute phase [query], all shards failed
异常。我正在使用Java API和elasticsearch 1.4v。任何线索都非常感谢。
这是示例JSON:
{ "_index":"vlan-active", "_source":{ "vlanId":8, "port":3, "vlanIP":"10.16.8.102", "ipv4":"10.16.8.102", "ipv6":"", "mac":"", "vendorName":"","os":""}}
最佳答案
term
查询将字段匹配为单个值。
为了匹配in clause
等多个值,应使用terms
代替term
。
我将关键字term
更改为terms
并使其正常运行。
关于java - Elasticsearch:如何在查询中使用聚合?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42556801/