Tuning BM25

One of the nice features of BM25 is that, unlike TF/IDF, it has two parameters that allow it to be tuned:

k1
This parameter controls how quickly an increase in term frequency results in term-frequency saturation. The default value is 1.2. Lower values result in quicker saturation, and higher values in slower saturation.
b
This parameter controls how much effect field-length normalization should have. A value of 0.0disables normalization completely, and a value of 1.0 normalizes fully. The default is 0.75.

The practicalities of tuning BM25 are another matter. The default values for k1 and b should be suitable for most document collections, but the optimal values really depend on the collection. Finding good values for your collection is a matter of adjusting, checking, and adjusting again.

The similarity algorithm can be set on a per-field basis. It’s just a matter of specifying the chosen algorithm in the field’s mapping:

PUT /my_index
{
"mappings": {
"doc": {
"properties": {
"title": {
"type": "string",
"similarity": "BM25"

        },
"body": {
"type": "string",
"similarity": "default"

        }
}
}
}

The title field uses BM25 similarity.

The body field uses the default similarity (see Lucene’s Practical Scoring Function).

Currently, it is not possible to change the similarity mapping for an existing field. You would need to reindex your data in order to do that.

Configuring BM25

Configuring a similarity is much like configuring an analyzer. Custom similarities can be specified when creating an index. For instance:

PUT /my_index
{
"settings": {
"similarity": {
"my_bm25": {

        "type": "BM25",
"b": 0

      }
}
},
"mappings": {
"doc": {
"properties": {
"title": {
"type": "string",
"similarity": "my_bm25"

        },
"body": {
"type": "string",
"similarity": "BM25"

        }
}
}
}
} 参考:https://www.elastic.co/guide/en/elasticsearch/guide/current/changing-similarities.html

ES 相似度算法设置(续)的更多相关文章

  1. ES BM25 TF-IDF相似度算法设置——

    Pluggable Similarity Algorithms Before we move on from relevance and scoring, we will finish this ch ...

  2. 文本相似度算法——空间向量模型的余弦算法和TF-IDF

    1.信息检索中的重要发明TF-IDF TF-IDF是一种统计方法,TF-IDF的主要思想是,如果某个词或短语在一篇文章中出现的频率TF高,并且在其他文章中很少出现,则认为此词或者短语具有很好的类别区分 ...

  3. 文本相似度 余弦值相似度算法 VS L氏编辑距离(动态规划)

    设置n为字符串s的长度.("我是个小仙女") 设置m为字符串t的长度.("我不是个小仙女") 如果n等于0,返回m并退出.如果m等于0,返回n并退出.构造两个向 ...

  4. python结巴分词余弦相似度算法实现

    过余弦相似度算法计算两个字符串之间的相关度,来对关键词进行归类.重写标题.文章伪原创等功能, 让你目瞪口呆.以下案例使用的母词文件均为txt文件,两种格式:一种内容是纯关键词的txt,每行一个关键词就 ...

  5. Spark/Scala实现推荐系统中的相似度算法(欧几里得距离、皮尔逊相关系数、余弦相似度:附实现代码)

    在推荐系统中,协同过滤算法是应用较多的,具体又主要划分为基于用户和基于物品的协同过滤算法,核心点就是基于"一个人"或"一件物品",根据这个人或物品所具有的属性, ...

  6. elasticsearch算法之词项相似度算法(一)

    一.词项相似度 elasticsearch支持拼写纠错,其建议词的获取就需要进行词项相似度的计算:今天我们来通过不同的距离算法来学习一下词项相似度算法: 二.数据准备 计算词项相似度,就需要首先将词项 ...

  7. ES设置查询的相似度算法

    similarity Elasticsearch allows you to configure a scoring algorithm or similarity per field. The si ...

  8. Java 比较两个字符串的相似度算法(Levenshtein Distance)

    转载自: https://blog.csdn.net/JavaReact/article/details/82144732 算法简介: Levenshtein Distance,又称编辑距离,指的是两 ...

  9. 百度面试题 字符串相似度 算法 similar_text 和页面相似度算法

    在百度的面试,简直就是花样求虐. 首先在面试官看简历的期间,除了一个自己定义字符串相似度,并且写出求相似度的算法. ...这个确实没听说过,php的similar_text函数也是闻所未闻的.之前看s ...

随机推荐

  1. js处理日期格式yyyy-MM-dd hh:mm:ss

    直接上代码: 使用方法: dateformat('h:m:s') => 09:08:11 dateformat('y-M-d h:m:s') => 2018-06-08 09:08:11 ...

  2. 【Excle数据透视】如何创建多条件汇总的数据透视表

    创建多条件的数据透视表,源数据如下: 插入数据透视表 根据需求拖拽字段(统计该地区下销售人员销售业绩) 数据透视结果 数据透视表布局的各个区域说明 区域 说明 数值 用于显示汇总值数据 行标签 用于将 ...

  3. GridView 获取列字段的几种途径

    GridView是ASP.NET中功能强大的数据显示控件,它的RowDataBound事件为我们提供了方便的控制行.列数据的途径. 要获取当前行的某个数据列,我在实践中总结有如下几种方法: 1. Ce ...

  4. DataTable行处理

    DataTable dt=new DataTable(); 新增行: DataRow addDR= mydatatable.NewRow();addDR["ID"] = " ...

  5. LeetCode Hash Table 3. Longest Substring Without Repeating Characters

    HashMap的应用可以提高查找的速度,键key,值value的使用拜托了传统数组的遍历查找方式,对于判断一个字符或者字符串是否已经存在的问题可以非常好的解决.而本题需要解决的问题就是判断新遍历到的字 ...

  6. sprint3 【每日scrum】 TD助手站立会议第四天

    站立会议 组员 昨天 今天 困难 签到 刘铸辉 (组长) 和楠哥学习了通过AlarmManager 来实现闹钟,由于要用到BroadcastReceiver广播协议,所以正在学习中,暂时只是按照教程写 ...

  7. 软件工程第2次作业——Visual Studio 2017下基于C/C++的VSTS单元测试实践

    Write one minute, test all day long. 环境确定 IDE:Microsoft Visual Studio 2017 Community 语言:C++ 单元测试工具:V ...

  8. erlang中通过ip和子网掩码,计算地址范围 【二进制和十进制的转换】

    在程序中,难免用的二进制和十进制之间的转换.遇到一个场景,通过ip和子网掩码,计算地址范围. 而地址范围为:网络地址+1—— 广播地址 -1 .  网络地址即ip和子网掩码的与的位运算.广播地址为:网 ...

  9. CocoaPods Podfile详解与使用

    1.为什么需要CocoaPods 在进行iOS开发的时候,总免不了使用第三方的开源库,比如SBJson.AFNetworking.Reachability等等.使用这些库的时候通常需要: 下载开源库的 ...

  10. 18- php Redis扩展编译

    一:php扩展编译Redis :wget http://pecl.php.net/get/redis-2.2.5.tgz :tar -zxvf redis-.tgz :cd redis- :/usr/ ...