boosting查询
positive部分: 查询返回的查询结果分值不变
negative部分: 查询的结果分值会被降低
negative_boost部分: 设置negative中要降低的分值, 相关性算分降低的程度将由 negative_boost 参数决定,其取值范围为:[0.0, 1.0]
优点: 里面的两个查询都会有结果返回,其中一个分值就是你设置的分值
注意:如果是设有bool的must_not的话,那降低的那部分就没有结果返回
POST books/_search{"query": {"boosting": {"positive": {"term": {"name": {"value": "linux"}}},"negative": {"term": {"name": {"value": "programming"}}},"negative_boost": 0.5}}}
如上示例,我们查询书名中含有 “linux” 的文档,并且想让含有 “programming” 字样的文档的相关性降低一半。在 negative 块中匹配的文档,其相关性算分为:在 positive 中匹配时的算分 * negative_boost。
bool对评分的影响
boost值
参数boost的含义
- 当boost > 1, 打分的相关度提升
- 当0 < boost < 1, 打分的权重降低
- 当 boost < 0, 贡献负分
GET /book/_search{"query": {"range": {"price": {"gte": 10,"lte": 200,"boost": 2.0}}}}
