【发布时间】:2019-03-21 19:01:26
【问题描述】:
我在official document找到了一些关于must_not的描述
must_not子句(查询)不能出现在匹配的文档中。子句在过滤器上下文中执行,这意味着忽略评分并考虑缓存子句。由于忽略了评分,因此返回所有文档的 0 分数。
它告诉我 must_not 将返回 0 分数,就像 filter 操作一样。但是当我执行这个查询时:
GET /my_idx/my_type/_search
{
"query": {
"bool": {
"must_not": [
{"match" : {"name": "Test"}}
]
}
}
}
响应显示:
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 6,
"max_score": 1,
"hits": [
{
"_index": "my_idx",
"_type": "my_type",
"_id": "Nbs5nmkBAfzcjFMf2czR",
"_score": 1,
"_source": {
"analyzer": "my_tokenizer",
"text": "Doe"
}
},
...
如您所见"_score": 1
为什么会这样?
【问题讨论】:
标签: elasticsearch