ElasticSearch:如何组合嵌套的'AND'不等于(ElasticSearch : How to combine nested 'AND' Not Equal)

我想构建查询匹配嵌套和不相等的搜索。

这是我的elasticSearch查询:

{ "from":0,"size":1000, "query":{ "nested" : { "path" : "data", "query" : { "match" : { "data.city" : "california" } } }, "filter":{ "not":{ "filter":{ "term":{ "_id":"01921asda01201" } } } } } }

但我得到了错误,我写错了什么? 谢谢

I want build query for search matching with nested and not equal.

This is my elasticSearch query:

{ "from":0,"size":1000, "query":{ "nested" : { "path" : "data", "query" : { "match" : { "data.city" : "california" } } }, "filter":{ "not":{ "filter":{ "term":{ "_id":"01921asda01201" } } } } } }

But I got error, am I write something wrong ? thanks

最满意答案

您也可以使用bool Filter和must和must_not子句。

{ "from": 0, "size": 1000, "filter": { "bool": { "must": [ { "nested": { "path": "data", "query": { "match": { "data.city": "california" } } } } ], "must_not": [ { "term": { "_id": "01921asda01201" } } ] } } }

You can use bool Filter too with must and must_not clause.

{ "from": 0, "size": 1000, "filter": { "bool": { "must": [ { "nested": { "path": "data", "query": { "match": { "data.city": "california" } } } } ], "must_not": [ { "term": { "_id": "01921asda01201" } } ] } } }

更多推荐