白话Elasticsearch12-深度探秘搜索技术之基于multi_match + best fields语法实现dis_max+tie_breaker
生活随笔
收集整理的這篇文章主要介紹了
白话Elasticsearch12-深度探秘搜索技术之基于multi_match + best fields语法实现dis_max+tie_breaker
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
文章目錄
- 概述
- 官網
- 示例
概述
繼續跟中華石杉老師學習ES,第十二篇
課程地址: https://www.roncoo.com/view/55
官網
https://www.elastic.co/guide/en/elasticsearch/reference/7.2/query-dsl-multi-match-query.html
示例
GET /forum/article/_search {"query": {"dis_max": {"queries": [{"match": {"title": {"query": "java beginner","minimum_should_match": "50%","boost": 2}}},{"match": {"content": {"query": "java beginner","minimum_should_match": "50%"}}}],"tie_breaker": 0.3}} }可以簡化為
GET /forum/article/_search {"query": {"multi_match": {"query": "java beginner","type": "best_fields","fields": ["title^2","content"],"tie_breaker": 0.3,"minimum_should_match": "50%"}} }minimum_should_match的主要用途 : 去長尾,long tail
長尾是什么呢,舉個例子:假設你搜索5個關鍵詞,但是很多結果是只匹配1個關鍵詞的,其實跟你想要的結果相差甚遠,這些結果就是長尾
minimum_should_match,控制搜索結果的精準度,只有匹配一定數量的關鍵詞的數據,才能返回
返回結果
{"took": 1,"timed_out": false,"_shards": {"total": 1,"successful": 1,"skipped": 0,"failed": 0},"hits": {"total": 5,"max_score": 1.4387287,"hits": [{"_index": "forum","_type": "article","_id": "2","_score": 1.4387287,"_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.2162449,"_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": "1","_score": 0.977973,"_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"}},{"_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"}}]} }總結
以上是生活随笔為你收集整理的白话Elasticsearch12-深度探秘搜索技术之基于multi_match + best fields语法实现dis_max+tie_breaker的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 白话Elasticsearch10-深度
- 下一篇: 白话Elasticsearch13-深度