Elasticsearch Compound Queries
Elasticsearch 的 Compound Queries 是一种强大的工具,用于组合多个查询子句,以实现更复杂的搜索逻辑。这些查询子句可以是叶查询(Leaf Queries)或复合查询(Compound Queries),并且可以用于组合结果和分数、改变行为或从查询上下文切换到过滤上下文。
主要的复合查询类型
-
bool查询:-
用于组合多个叶查询或复合查询子句,支持
must、should、must_not和filter子句。must和should子句的分数会被合并,而must_not和filter子句在过滤上下文中执行。
JSON复制
GET /products/_search { "query": { "bool": { "must": [ { "match": { "description": "wireless headphones" } } ], "filter": [ { "term": { "brand": "BrandA" } } ], "should": [ { "range": { "price": { "lte": 100 } } } ], "must_not": [ { "term": { "color": "red" } } ] } } } -
-
boosting查询:

最低0.47元/天 解锁文章

1117

被折叠的 条评论
为什么被折叠?



