Meaning must and operator combination


(雪中的凤凰) #1
POST news/bursa/_search { "query": { "bool": { "must": [{ "match": { "category": "36" } } ],"must": [ { "multi_match": { "query": [ "4448.KL","6599.KL" ], "fields": [ "stkno", "tag" ,"content" ,"htext" ] ,"operator": "and"} } ],"must": [{ "range": { "CDate": { "gt": "2010-01-01" , "lte": "2017-05-30T23:59:59" } } } ] } }, "size": 1000, "sort": [ { "CDate": { "order": "desc" } } ] }}

what meaning if must and operator combine together?
Why it only can match 6599.KL, and 4448.KL can't find? 4448.KL and 6599.KL sure inside elasticsearch.
If i wan search if 4448.KL also have inside the data, result also need prompt out. How should be i do?


(Zachary Tong) #2

"Must" clause says that all of the clauses "must match" for the document to be a hit. E.g. it is very similar to a boolean AND: this AND that AND theOther

I suggest reading through the Fulltext Search chapter of the Definitive Guide for more info on how queries are constructed: https://www.elastic.co/guide/en/elasticsearch/guide/current/full-text-search.html

In particular, this section on boolean queries: https://www.elastic.co/guide/en/elasticsearch/guide/current/bool-query.html


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.