我的dsl查询看起来像下面。
{
"query": {
"bool": {
"must": {
"match_all": {}
},
"filter": [{
"terms": {
"field": {...}
}],
"adjust_pure_negative": "false";
}
}
}
}
字符串
当我将标记adjust_pure_negative更改为true时,我不会得到任何记录,并且true是默认值。
2条答案
按热度按时间c8ib6hqw1#
不知道为什么当你把标志“adjust_pure_negative”改为true时没有记录,但是当你的ElasticSearch查询中只有一个“must-not”子句,并且“adjust_pure_negative”被设置为false时。然后,ElasticSearch将认为您希望完全不匹配任何内容[因为没有任何内容可以找到相似性]。因此,查询将不返回“must-not”子句的结果。因此,为了克服这个问题,我们将“adjust_pure_negative”设置为true。
这有点荒谬。因此,在后来的版本中,该标志被删除并硬编码为true。
iq3niunx2#
当查询中包含所有“must_not”子句时,则为了获得查询结果,
adjust_pure_negative
需要被发送为真,字符串
此查询将导致0个命中,同时数据存在于索引中。当设置
"adjust_pure_negative": true
时,它将返回命中。Elastic Lucene期望查询中有一些肯定子句,如果查询中没有肯定子句,Elasticsearch将使用此标志并添加must
match_all
子句。来源:https://discuss.elastic.co/t/what-does-adjust-pure-negative-flag-do/92348