ElasticSearch中如何让query should等同于filter should

快来打我* 2022-09-19 12:12 211阅读 0赞

bool query
















must

The clause (query) must appear in matching documents.

should

The clause (query) should appear in the matching document. In a boolean query with no must clauses, one or more should clauses must match a document. The minimum number of should clauses to match can be set using the minimum_should_matchparameter.

must_not

The clause (query) must not appear in the matching documents.

The bool query also supports disable_coord parameter (defaults to false). Basically the coord similarity computes a score factor based on the fraction of all query terms that a document contains. See Lucene BooleanQuery for >{
“bool” : {
“must” : {
“term” : { “user” : “kimchy” }
},
“must_not” : {
“range” : {
“age” : { “from” : 10, “to” : 20 }
}
},
“should” : [
{
“term” : { “tag” : “wow” }
},
{
“term” : { “tag” : “elasticsearch” }
}
],
“minimum_should_match” : 1,
“boost” : 1.0
}
}

本文出自:
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html

minimum_should_match 使用效果:bool query 中的should条件会过滤,相当于bool filter中should;且只能紧跟bool query中的should后面使用,其它位置会报异常

发表评论

表情:
评论列表 (有 0 条评论,211人围观)

还没有评论,来说两句吧...

相关阅读