文章目录

  • 概述
  • 官方文档
  • 例子
    • tie_breaker

概述

继续跟中华石杉老师学习ES,第十一篇

课程地址: https://www.roncoo.com/view/55


官方文档

https://www.elastic.co/guide/en/elasticsearch/guide/current/_tuning_best_fields_queries.html

https://www.elastic.co/guide/en/elasticsearch/reference/7.2/query-dsl-dis-max-query.html


例子

数据同 上篇博文 构造索引的DSL

这次我们使用dis_max查询 java beginner , DSL如下

GET /forum/article/_search
{"query": {"dis_max": {"queries": [{"match": {"title": "java beginner"}},{"match": {"content": "java beginner"}}]}}
}

返回

{"took": 2,"timed_out": false,"_shards": {"total": 1,"successful": 1,"skipped": 0,"failed": 0},"hits": {"total": 5,"max_score": 1.0341108,"hits": [{"_index": "forum","_type": "article","_id": "3","_score": 1.0341108,"_source": {"articleID": "JODL-X-1937-#pV7","userID": 2,"hidden": false,"postDate": "2017-01-01","tag": ["hadoop"],"tag_cnt": 1,"view_cnt": 100,"title": "this is elasticsearch blog","content": "i am only an elasticsearch beginner"}},{"_index": "forum","_type": "article","_id": "2","_score": 0.93952733,"_source": {"articleID": "KDKE-B-9947-#kL5","userID": 1,"hidden": false,"postDate": "2017-01-02","tag": ["java"],"tag_cnt": 1,"view_cnt": 50,"title": "this is java blog","content": "i think java is the best programming language"}},{"_index": "forum","_type": "article","_id": "4","_score": 0.79423964,"_source": {"articleID": "QQPX-R-3956-#aD8","userID": 2,"hidden": true,"postDate": "2017-01-02","tag": ["java","elasticsearch"],"tag_cnt": 2,"view_cnt": 80,"title": "this is java, elasticsearch, hadoop blog","content": "elasticsearch and hadoop are all very good solution, i am a beginner"}},{"_index": "forum","_type": "article","_id": "5","_score": 0.7116974,"_source": {"articleID": "DHJK-B-1395-#Ky5","userID": 3,"hidden": false,"postDate": "2019-05-01","tag": ["elasticsearch"],"tag_cnt": 1,"view_cnt": 10,"title": "this is spark blog","content": "spark is best big data solution based on scala ,an programming language similar to java"}},{"_index": "forum","_type": "article","_id": "1","_score": 0.4889865,"_source": {"articleID": "XHDK-A-1293-#fJ3","userID": 1,"hidden": false,"postDate": "2017-01-01","tag": ["java","hadoop"],"tag_cnt": 2,"view_cnt": 30,"title": "this is java and elasticsearch blog","content": "i like to write best elasticsearch article"}}]}
}

不知道为啥id=3的相关度是最高的… 如果有知道的,烦请不吝赐教。

dis_max只取某一个query最大的分数,完全不考虑其他query的分数


tie_breaker

使用tie_breaker将其他query的分数也考虑进去

tie_breaker参数的意义,在于说,将其他query的分数,乘以tie_breaker,然后综合与最高分数的那个query的分数,综合在一起进行计算,除了取最高分以外,还会考虑其他的query的分数。

tie_breaker的值,在0~1之间,是个小数。

GET /forum/article/_search
{"query": {"dis_max": {"queries": [{"match": {"title": "java beginner"}},{"match": {"content": "java beginner"}}],"tie_breaker": 0.7}}
}

返回结果

{"took": 2,"timed_out": false,"_shards": {"total": 1,"successful": 1,"skipped": 0,"failed": 0},"hits": {"total": 5,"max_score": 1.344432,"hits": [{"_index": "forum","_type": "article","_id": "2","_score": 1.344432,"_source": {"articleID": "KDKE-B-9947-#kL5","userID": 1,"hidden": false,"postDate": "2017-01-02","tag": ["java"],"tag_cnt": 1,"view_cnt": 50,"title": "this is java blog","content": "i think java is the best programming language"}},{"_index": "forum","_type": "article","_id": "4","_score": 1.1365302,"_source": {"articleID": "QQPX-R-3956-#aD8","userID": 2,"hidden": true,"postDate": "2017-01-02","tag": ["java","elasticsearch"],"tag_cnt": 2,"view_cnt": 80,"title": "this is java, elasticsearch, hadoop blog","content": "elasticsearch and hadoop are all very good solution, i am a beginner"}},{"_index": "forum","_type": "article","_id": "3","_score": 1.0341108,"_source": {"articleID": "JODL-X-1937-#pV7","userID": 2,"hidden": false,"postDate": "2017-01-01","tag": ["hadoop"],"tag_cnt": 1,"view_cnt": 100,"title": "this is elasticsearch blog","content": "i am only an elasticsearch beginner"}},{"_index": "forum","_type": "article","_id": "5","_score": 0.7116974,"_source": {"articleID": "DHJK-B-1395-#Ky5","userID": 3,"hidden": false,"postDate": "2019-05-01","tag": ["elasticsearch"],"tag_cnt": 1,"view_cnt": 10,"title": "this is spark blog","content": "spark is best big data solution based on scala ,an programming language similar to java"}},{"_index": "forum","_type": "article","_id": "1","_score": 0.4889865,"_source": {"articleID": "XHDK-A-1293-#fJ3","userID": 1,"hidden": false,"postDate": "2017-01-01","tag": ["java","hadoop"],"tag_cnt": 2,"view_cnt": 30,"title": "this is java and elasticsearch blog","content": "i like to write best elasticsearch article"}}]}
}

白话Elasticsearch11-深度探秘搜索技术之基于tie_breaker参数优化dis_max搜索效果相关推荐

  1. Elasticsearch 论坛实战-基于tie_breaker参数优化dis_max搜索效果

    Elasticsearch实战 准备数据 PUT /forum/post/_bulk {"index":{"_id":1}} {"title" ...

  2. 白话Elasticsearch18-深度探秘搜索技术之基于slop参数实现近似匹配以及原理剖析

    文章目录 概述 官网 slop 含义 例子 示例一 示例二 示例三 概述 继续跟中华石杉老师学习ES,第18篇 课程地址: https://www.roncoo.com/view/55 接上篇博客 白 ...

  3. 白话Elasticsearch20-深度探秘搜索技术之使用rescoring机制优化近似匹配搜索的性能

    文章目录 概述 官网 match和phrase match(proximity match)区别 优化proximity match的性能 概述 继续跟中华石杉老师学习ES,第19篇 课程地址: ht ...

  4. 白话Elasticsearch13-深度探秘搜索技术之基于multi_match+most fields策略进行multi-field搜索

    文章目录 概述 官网 示例 构造模拟数据 普通查询 使用 multi_match + most fileds查询 best fields VS most fields 概述 继续跟中华石杉老师学习ES ...

  5. 白话Elasticsearch10-深度探秘搜索技术之基于dis_max实现best fields策略进行多字段搜索

    文章目录 概述 TF/IDF 链接 示例 DSL 普通查询 dis_max 查询 best fields策略-dis_max 概述 继续跟中华石杉老师学习ES,第十篇 课程地址: https://ww ...

  6. 白话Elasticsearch14-深度探秘搜索技术之基于multi_match 使用most_fields策略进行cross-fields search弊端

    文章目录 概述 官网 示例 概述 继续跟中华石杉老师学习ES,第十四篇 课程地址: https://www.roncoo.com/view/55 官网 https://www.elastic.co/g ...

  7. 白话Elasticsearch12-深度探秘搜索技术之基于multi_match + best fields语法实现dis_max+tie_breaker

    文章目录 概述 官网 示例 概述 继续跟中华石杉老师学习ES,第十二篇 课程地址: https://www.roncoo.com/view/55 官网 https://www.elastic.co/g ...

  8. 白话Elasticsearch08-深度探秘搜索技术之基于boost的细粒度搜索条件权重控制

    文章目录 概述 boost 示例 概述 继续跟中华石杉老师学习ES,第八篇 课程地址: https://www.roncoo.com/view/55 boost https://www.elastic ...

  9. 白话Elasticsearch07- 深度探秘搜索技术之基于term+bool实现的multiword搜索底层剖析

    文章目录 概述 普通match转换为term+should and match转换为term+must minimum_should_match如何转换 概述 继续跟中华石杉老师学习ES,第七篇 课程 ...

最新文章

  1. C++默认参数注意事项
  2. ICLR 2020共计198篇开源代码论文合集!
  3. 还在为DST模型刷不动而感到苦恼吗?来试试无监督DST吧,DSI等你来战!
  4. 计算机科学与技术初级知识,计算机科学与技术专业课程有哪些
  5. linux 文件mtime,linux 文件的atime,ctime,mtime查看與修改
  6. SpringBoot使用外置的Servlet容器
  7. 小程序统一服务消息_微信团队发布小程序模板消息能力调整通知:小程序订阅消息接口正式上线...
  8. [转载] $CF290F$ 题解
  9. 类似print shopmail可变数据生成,排版、拼版实现
  10. 个人观点:苹果对iPad商标事件的解决办法
  11. 【最后有彩蛋】Pyhton接口测试手册
  12. 固态硬盘跟机械硬盘是怎么储存数据
  13. win11安装mysql8.0.29最新压缩包版
  14. RK3399 ARM开发板添加中文输入法
  15. 13个优秀的UML工具软件
  16. 讲道理 | 计算正交投影算子
  17. MyBatis框架快速入门
  18. python证书微软认证_怎样考取微软工程师?
  19. 什么是人脸识别,人脸识别的主要分为哪几步?
  20. Openbravo 3.0 安装及优缺点简述

热门文章

  1. QT Quick项目简介
  2. kmeans及模型评估指标_如何评估聚类模型?兰德指数、轮廓系数、Calinski Harabaz指数...
  3. 威胁快报|首爆,新披露Jenkins RCE漏洞成ImposterMiner挖矿木马新“跳板”
  4. 3.3 自动驾驶的安全结构(第三章 自动驾驶汽车的安全保障)
  5. LC滤波器设计学习笔记(一)滤波电路入门
  6. SpringBoot-项目4-购物车(添加入购物车,购物车列表,购物车商品数量加减操作)
  7. ospf协议说明之top思路图
  8. 阿西莫夫:编造幻想与使之跟事实融为一体是两件事
  9. 计算机网络 传输媒体 光缆,软考网络管理员笔记之计算机网络传输媒体
  10. 良心推荐几款好玩的生存类手游:方舟生存进化、饥荒等等