一、query DSL
叶子查询
于特定字段查询特定值。如 match
, term
或 range
查询
复合查询
包装其它叶子查询或复合查询。如使用 bool
or dis_max
混合多个查询
分离最大化查询 dis_max
分离最大化查询(Disjunction Max Query)指的是: 将任何与任一查询匹配的文档作为结果返回,但只将最佳匹配的评分作为查询的评分结果返回,而不是将所有匹配结果的得分相加。
示例:
{ "query": { "dis_max": { "queries": [ { "match": { "title": "Brown fox" }}, { "match": { "body": "Brown fox" }} ] } } }
返回
{ "hits": [ { "_id": "2", "_score": 0.21509302, "_source": { "title": "Keeping pets healthy", "body": "My quick brown fox eats rabbits on a regular basis." } }, { "_id": "1", "_score": 0.12713557, "_source": { "title": "Quick brown rabbits", "body": "Brown rabbits are commonly seen." } } ] }
参考文档
https://www.elastic.co/guide/cn/elasticsearch/guide/current/_best_fields.html
https://www.elastic.co/guide/cn/elasticsearch/guide/current/_tuning_best_fields_queries.html
原文地址:https://www.cnblogs.com/lemos/p/12536480.html
时间: 2024-10-15 05:29:55