ES设置查询的相似度算法
similarity
Elasticsearch allows you to configure a scoring algorithm or similarity per field. The similaritysetting provides a simple way of choosing a similarity algorithm other than the default BM25, such as TF/IDF.
Similarities are mostly useful for text fields, but can also apply to other field types.
Custom similarities can be configured by tuning the parameters of the built-in similarities. For more details about this expert options, see the similarity module.
The only similarities which can be used out of the box, without any further configuration are:
BM25- The Okapi BM25 algorithm. The algorithm used by default in Elasticsearch and Lucene. See Pluggable Similarity Algorithms for more information.
classic- The TF/IDF algorithm which used to be the default in Elasticsearch and Lucene. See Lucene’s Practical Scoring Function for more information.
boolean- A simple boolean similarity, which is used when full-text ranking is not needed and the score should only be based on whether the query terms match or not. Boolean similarity gives terms a score equal to their query boost.
The similarity can be set on the field level when a field is first created, as follows:
PUT my_index
{
"mappings": {
"my_type": {
"properties": {
"default_field": {
![]()
"type": "text"
},
"classic_field": {
"type": "text",
"similarity": "classic"
![]()
},
"boolean_sim_field": {
"type": "text",
"similarity": "boolean"
![]()
}
}
}
}
}
|
|
The |
|
|
The |
|
|
The |
Default and Base Similarities
By default, Elasticsearch will use whatever similarity is configured as default. However, the similarity functions queryNorm() and coord() are not per-field. Consequently, for expert users wanting to change the implementation used for these two methods, while not changing the default, it is possible to configure a similarity with the name base. This similarity will then be used for the two methods.
You can change the default similarity for all fields in an index when it is created:
PUT /my_index
{
"settings": {
"index": {
"similarity": {
"default": {
"type": "classic"
}
}
}
}
}
If you want to change the default similarity after creating the index you must close your index, send the follwing request and open it again afterwards:
PUT /my_index/_settings
{
"settings": {
"index": {
"similarity": {
"default": {
"type": "classic"
}
}
}
}
} from:https://www.elastic.co/guide/en/elasticsearch/reference/5.4/index-modules-similarity.html
ES设置查询的相似度算法的更多相关文章
- 文本相似度算法——空间向量模型的余弦算法和TF-IDF
1.信息检索中的重要发明TF-IDF TF-IDF是一种统计方法,TF-IDF的主要思想是,如果某个词或短语在一篇文章中出现的频率TF高,并且在其他文章中很少出现,则认为此词或者短语具有很好的类别区分 ...
- 文本相似度 余弦值相似度算法 VS L氏编辑距离(动态规划)
设置n为字符串s的长度.("我是个小仙女") 设置m为字符串t的长度.("我不是个小仙女") 如果n等于0,返回m并退出.如果m等于0,返回n并退出.构造两个向 ...
- Atitit.列表页面and条件查询的实现最佳实践(1)------设置查询条件and提交查询and返回json数据
Atitit.列表页面and条件查询的实现最佳实践(1)------设置查询条件and提交查询and返回json数据 1. 1. 配置条件字段@Conditional 1 1 2. 2. 配置条件字段 ...
- ES : 软件工程学的复杂度理论及物理学解释
系统论里面总是有一些通用的专业术语 比如复杂度.熵.焓,复杂度专门独立出来,成为复杂度理论 文章摘抄于:<非线性动力学> 刘秉政 编著 5.5 复杂性及其测度 热力学的几个专业术语 熵. ...
- python结巴分词余弦相似度算法实现
过余弦相似度算法计算两个字符串之间的相关度,来对关键词进行归类.重写标题.文章伪原创等功能, 让你目瞪口呆.以下案例使用的母词文件均为txt文件,两种格式:一种内容是纯关键词的txt,每行一个关键词就 ...
- ES 复合查询
ES在查询过程中比较多遇到符合查询,既需要多个字段过滤也需要特殊情况处理,本文简单介绍几种查询组合方便快捷查询ES. bool布尔查询有一个或者多个布尔子句组成 filter 只过滤符合条件的 ...
- Spark/Scala实现推荐系统中的相似度算法(欧几里得距离、皮尔逊相关系数、余弦相似度:附实现代码)
在推荐系统中,协同过滤算法是应用较多的,具体又主要划分为基于用户和基于物品的协同过滤算法,核心点就是基于"一个人"或"一件物品",根据这个人或物品所具有的属性, ...
- elasticsearch算法之词项相似度算法(一)
一.词项相似度 elasticsearch支持拼写纠错,其建议词的获取就需要进行词项相似度的计算:今天我们来通过不同的距离算法来学习一下词项相似度算法: 二.数据准备 计算词项相似度,就需要首先将词项 ...
- es的查询、排序查询、分页查询、布尔查询、查询结果过滤、高亮查询、聚合函数、python操作es
今日内容概要 es的查询 Elasticsearch之排序查询 Elasticsearch之分页查询 Elasticsearch之布尔查询 Elasticsearch之查询结果过滤 Elasticse ...
随机推荐
- HDU 1113 Word Amalgamation (map 容器 + string容器)
http://acm.hdu.edu.cn/showproblem.php?pid=1113 Problem Description In millions of newspapers across ...
- 0x20 搜索
这里基本就是入门吧. 可达性统计 用bitset搞的判重,发现这东西是真好用哈,空间还小 #include<cstdio> #include<iostream> #includ ...
- 8.MATLAB数据分析
概述: clc; clear all; p1=[ ]; y=poly2sym(p1) %由向量创建多项式 disp(y) %显示多项式 1 多项式的求值与求根 clc; clear all; p=[ ...
- POJ 1155 树形DP
题意:电视台发送信号给很多用户,每个用户有愿意出的钱,电视台经过的路线都有一定费用,求电视台不损失的情况下最多给多少用户发送信号. 转自:http://www.cnblogs.com/andre050 ...
- Android 制作类似支付圆圈和打钩界面ProgressWheel
首先要说明的是,制作圆圈旋转的效果并不是博主做的,是参照了github上的一个代码,只是在上面添加了修改,对其优化并增加了一个打钩的动画. 先来看下效果,1+的手机获取root权限真是难,没法录屏,只 ...
- svn中有的代码被标注黄色,绿色和红色,分别表示什么意思呢?
1.红色感叹号表示这个文件从服务器上下载下来以后,在本地被修改过.这时执行提交操作就可以了.2.黄色感叹号表示这个文件在提交的时候发现存在冲突,也就是说有别人在你提交之前对这个文件的同一个版本进行了修 ...
- easyui的增删改
陈旧的开发模式PM:“我要这个功能”后端:“这个先找前端做个模板”前端:“模板做完了”后端:“我来对接一下,这里样式不对”前端:“我改完了”后端:“功能交付”PM:“春节要加这个活动”后端:“这个先找 ...
- CF949A Zebras 构造
是一道不错的构造题. 我们观察,一个 111 的前后必须都有 000. 那么,我们开一个二维数组 (vector)(vector)(vector),这样每遇到一个 000 就将 000 加入到当前的 ...
- 洛谷 P1313 计算系数 (二项式定理)
这道题正好复习了二项式定理 所以答案就是a^n * b^m * c(n, k) 然后注意一些细节 我一开始写组合数只写一行的组合数 即c[0] = 1; c[i] = c[i-1] * (n - i ...
- STM32 GPIO重映射(转)
重映射就是将引脚功能重新定义到其他引脚, 例如PA9是USART1-TX默认的 管脚,但是现在PA9用做它用了,那可以将USART1-TX重新映射到PB6,当然这 种映射不是随意的想映射到哪个脚就哪个 ...