Elasticsearch 之(20)proximity match 近似匹配
1、什么是近似匹配
{"match": {"content": "java spark"}
}
2、match_phrase
GET /forum/article/_search
{"query": {"match": {"content": "java spark"}}
}
POST /forum/article/5/_update
{"doc": {"content": "spark is best big data solution based on scala ,an programming language similar to java spark"}
}
GET /forum/article/_search
{"query": {"match_phrase": {"content": "java spark"}}
}
3、term position
GET _analyze
{"text": "hello world, java spark","analyzer": "standard"
}{"tokens": [{"token": "hello","start_offset": 0,"end_offset": 5,"type": "<ALPHANUM>","position": 0},{"token": "world","start_offset": 6,"end_offset": 11,"type": "<ALPHANUM>","position": 1},{"token": "java","start_offset": 13,"end_offset": 17,"type": "<ALPHANUM>","position": 2},{"token": "spark","start_offset": 18,"end_offset": 23,"type": "<ALPHANUM>","position": 3}]
}
4、match_phrase的基本原理
slop
GET /forum/article/_search
{"query": {"match_phrase": {"title": {"query": "java spark","slop": 1}}}
}
GET /forum/article/_search
{"query": {"match_phrase": {"title": {"query": "java spark","slop": 3}}}
}
GET /forum/article/_search
{"query": {"match_phrase": {"content": {"query": "spark data","slop": 3}}}
}
GET /forum/article/_search
{"query": {"match_phrase": {"content": {"query": "data spark","slop": 5}}}
}
GET /forum/article/_search
{"query": {"match_phrase": {"content": {"query": "java best","slop": 15}}}
}{"took": 3,"timed_out": false,"_shards": {"total": 5,"successful": 5,"failed": 0},"hits": {"total": 2,"max_score": 0.65380025,"hits": [{"_index": "forum","_type": "article","_id": "2","_score": 0.65380025,"_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","sub_title": "learned a lot of course","author_first_name": "Smith","author_last_name": "Williams","new_author_last_name": "Williams","new_author_first_name": "Smith"}},{"_index": "forum","_type": "article","_id": "5","_score": 0.07111243,"_source": {"articleID": "DHJK-B-1395-#Ky5","userID": 3,"hidden": false,"postDate": "2017-03-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 spark","sub_title": "haha, hello world","author_first_name": "Tonny","author_last_name": "Peter Smith","new_author_last_name": "Peter Smith","new_author_first_name": "Tonny"}}]}
}
召回率
精准度
GET /forum/article/_search
{"query": {"bool": {"must": {"match": { "title": {"query": "java spark" --> java或spark或java spark,java和spark靠前,但是没法区分java和spark的距离,也许java和spark靠的很近,但是没法排在最前面}}},"should": {"match_phrase": { --> 在slop以内,如果java spark能匹配上一个doc,那么就会对doc贡献自己的relevance score,如果java和spark靠的越近,那么就分数越高"title": {"query": "java spark","slop": 50}}}}}
}
对比 match phrase,proximity match查询结果
GET /forum/article/_search
{"query": {"bool": {"must": [{"match": {"content": "java spark"}}]}}
}{"took": 5,"timed_out": false,"_shards": {"total": 5,"successful": 5,"failed": 0},"hits": {"total": 2,"max_score": 0.68640786,"hits": [{"_index": "forum","_type": "article","_id": "2","_score": 0.68640786,"_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","sub_title": "learned a lot of course","author_first_name": "Smith","author_last_name": "Williams","new_author_last_name": "Williams","new_author_first_name": "Smith","followers": ["Tom","Jack"]}},{"_index": "forum","_type": "article","_id": "5","_score": 0.68324494,"_source": {"articleID": "DHJK-B-1395-#Ky5","userID": 3,"hidden": false,"postDate": "2017-03-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 spark","sub_title": "haha, hello world","author_first_name": "Tonny","author_last_name": "Peter Smith","new_author_last_name": "Peter Smith","new_author_first_name": "Tonny","followers": ["Jack","Robbin Li"]}}]}
}
GET /forum/article/_search
{"query": {"bool": {"must": [{"match": {"content": "java spark"}}],"should": [{"match_phrase": {"content": {"query": "java spark","slop": 50}}}]}}
}{"took": 5,"timed_out": false,"_shards": {"total": 5,"successful": 5,"failed": 0},"hits": {"total": 2,"max_score": 1.258609,"hits": [{"_index": "forum","_type": "article","_id": "5","_score": 1.258609,"_source": {"articleID": "DHJK-B-1395-#Ky5","userID": 3,"hidden": false,"postDate": "2017-03-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 spark","sub_title": "haha, hello world","author_first_name": "Tonny","author_last_name": "Peter Smith","new_author_last_name": "Peter Smith","new_author_first_name": "Tonny","followers": ["Jack","Robbin Li"]}},{"_index": "forum","_type": "article","_id": "2","_score": 0.68640786,"_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","sub_title": "learned a lot of course","author_first_name": "Smith","author_last_name": "Williams","new_author_last_name": "Williams","new_author_first_name": "Smith","followers": ["Tom","Jack"]}}]}
}
match和phrase match(proximity match)区别
rescore(重打分)
GET /forum/article/_search
{"query": {"match": {"content": "java spark"}},"rescore": {"window_size": 50,"query": {"rescore_query": {"match_phrase": {"content": {"query": "java spark","slop": 50}}}}}
}
Elasticsearch 之(20)proximity match 近似匹配相关推荐
- ElasticSearch教程——proximity match 近似匹配
ElasticSearch汇总请查看:ElasticSearch教程--汇总篇 1.什么是近似匹配 两个句子 java is my favourite programming language, an ...
- ElasticSearch 2 (20) - 语言处理系列之如何开始
ElasticSearch 2 (20) - 语言处理系列之如何开始 摘要 Elasticsearch 配备了一组语言分析器,为世界上大多数常见的语言提供良好的现成基础支持. 阿拉伯语.亚美尼亚语,巴 ...
- Elasticsearch中的Multi Match Query
在Elasticsearch全文检索中,我们用的比较多的就是Multi Match Query,其支持对多个字段进行匹配.Elasticsearch支持5种类型的Multi Match,我们一起来深入 ...
- Elasticsearch 2.20入门篇:基本操作
2019独角兽企业重金招聘Python工程师标准>>> 前面我们已经安装了Elasticsearch ,下一步我们要对Elasticsearch进行一些基本的操作.基本的操作主要有, ...
- Elasticsearch查询之term/match解析
2019独角兽企业重金招聘Python工程师标准>>> es种有两种查询模式,一种是像传递URL参数一样去传递查询语句,被称为简单搜索或查询字符串(query string)搜索,比 ...
- elasticsearch中term与match
分词器.字符串类型.倒排索引 在说term和match之前,需要先了解一下这三个概念 分词器 es默认的分词器是standard analyzer,该分词器的特点是:将所有英文字符串的大写字母转换成小 ...
- Elasticsearch全文检索对比:match、match_phrase、wildcard
文章目录 match match_phrase wildcard match 根据定义的分词器(默认standard)对搜索词进行拆分,根据拆分结果逐个进行匹配.特点是可以查出大量可能相关联的数据,但 ...
- ElasticSearch教程——汇总篇
环境搭建篇 ElasticSearch教程--安装 ElasticSearch教程--安装Head插件 ElasticSearch教程--安装IK分词器插件 ElasticSearch教程--安装Ki ...
- (转)ElasticSearch教程——汇总篇
https://blog.csdn.net/gwd1154978352/article/details/82781731 环境搭建篇 ElasticSearch教程--安装 ElasticSearch ...
最新文章
- kylin KV+cube方案分析
- python的相对路径导入问题
- U3D-LookAt插值动画
- 浙江理工大学-2018-2019学年面向对象程序设计A-期末复习资料
- Atom工具总结笔记
- 一日一技:ASP.NET Core 判断请求是否为Ajax请求
- matlab GUI 设计 自学笔记
- CentOS关闭图形界面(x window)
- mysql数据量很少查询却很慢_Mysql索引
- C++ 10进制字符串转10进制 10进制字符串转换
- Possible missing firmware
- UE4 粒子特效基础学习 (03-制作上升光线特效)
- 2116: 简简单单的数学题(快速幂||爆longlong处理)
- 学习日记day29 平面设计 色彩
- Spark Streaming简单入门(示例+原理)
- 如何发送国际短信更便宜、更稳定?
- Chrome浏览器默认全屏启动(非--kiosk模式)
- DNS劫持、流量劫持,HTTP/HTTPS劫持
- Python类型转换——数据类型转换函数大全
- 不格式化移动硬盘(u盘)做成pe
热门文章
- 南京 学计算机的学校,南京小学生暑假学计算机编程去哪家学校好
- 【信息安全】数据安全与信息安全
- Java程序在结构上的特点_下面关于JavaApplication程序结构特点描述中,错误的是()...
- 白色/黄色/开关型/罗丹明B染料标记希夫碱/半胱氨酸乙酯荧光探针的制备过程
- Python快速编程入门#学习笔记06# |第6章 :函数(学生管理系统)
- 网站运行原理及开发流程
- 《秘密全在小动作上》读书笔记
- 2021年美容师(初级)报名考试及美容师(初级)模拟考试题
- CSS浮动+背景图片+边框+文字排版+段落设置
- todo有android版本吗,高效todo手机app下载