為什么must_not就不生效呢?mapping:"text_terms": { "type": "nested", "properties": { "term": { "type": "string", "index": "not_analyzed"
}, "freq": { "type": "integer"
}
}
}數(shù)據(jù){ "text_terms" : [ { "term" : "aaa", "freq" : 1 }, { "term" : "bbb", "freq" : 1 }, { "term" : "ccc", "freq" : 1 } ] }
{ "text_terms" : [ { "term" : "aaa", "freq" : 1 }, { "term" : "西門子", "freq" : 1 }, { "term" : "ccc", "freq" : 1 } ] }
{ "text_terms" : [ { "term" : "ccc", "freq" : 1 }, { "term" : "西門子", "freq" : 1 }, { "term" : "ddd", "freq" : 1 } ] }
{ "text_terms" : [ { "term" : "ddd", "freq" : 1 }, { "term" : "eee", "freq" : 1 } ] }查詢包含西門子的記錄 沒有問題 能查出包含西門子的兩條記錄"query": { "nested": { "query": { "bool": { "must": [{ "term": { "text_terms.term": "西門子" } }] } }, "path": "text_terms" } }但是查詢不包含西門子的記錄時(shí) 就不生效了呢?"query": { "nested": { "query": { "bool": { "must_not": [{ "term": { "text_terms.term": "西門子" } }] } }, "path": "text_terms" } }怎么此時(shí)四條記錄都能查出來呢?
為什么查詢不包含某個(gè)詞的記錄時(shí) must_not不生效呢?
慕斯王
2018-07-23 21:04:03