目前为止,我们已经知道多词条的match queries只是把term query简单的包装了下使用在bool query中,默认情况使用or操作符,它表示每个term query会被加入到should参数中,所以它必须至少满足should参数中指定的查询子句中的一个。
如下两个查询其实是等效的:
{ "match": { "title": "brown fox"}}
{ "bool": { "should": [ { "term": { "title": "brown" }}, { "term": { "title": "fox" }} ] }}如果我们在match query使用and操作符,如下两个查询是等效的:
{ "match": { "title": { "query": "brown fox", "operator": "and" } }}
{ "bool": { "must": [ { "term": { "title": "brown" }}, { "term": { "title": "fox" }} ] }}如果使用minimum_should_match参数,下面两个查询也是等效的:
{ "match": { "title": { "query": "quick brown fox", "minimum_should_match": "75%" } }}
{ "bool": { "should": [ { "term": { "title": "brown" }}, { "term": { "title": "fox" }}, { "term": { "title": "quick" }} ], "minimum_should_match": 2 }}当然,我们还是在开发中还是正常的使用match query,上面的例子只是为了我们更好的理解match,让我们在开发中能更好的控制match query