码迷,mamicode.com
首页 > 其他好文 > 详细

Elasticsearch学习之相关度评分TF&IDF

时间:2017-06-26 10:26:31      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:length   关联   font   计算   orm   inverse   mil   pre   算法   

relevance score算法,简单来说,就是计算出,一个索引中的文本,与搜索文本,他们之间的关联匹配程度

Elasticsearch使用的是 term frequency/inverse document frequency算法,简称为TF/IDF算法

Term frequency(TF):搜索文本中的各个词条在field文本中出现了多少次,出现次数越多,就越相关

Inverse document frequency(IDF):搜索文本中的各个词条在整个索引的所有文档中出现了多少次,出现的次数越多,就越不相关

示例:

搜索请求:hello world

doc1:hello, today
is very good doc2:hi world, how are you
比如说,在index中有1万条document,hello这个单词在所有的document中,一共出现了1000次;world这个单词在所有的document中,一共出现了100次 doc2更相关

Field-length norm:field长度,field越长,相关度越弱

doc1:{ "title": "hello article", "content": "babaaba 1万个单词" }
doc2:{ "title": "my article", "content": "blablabala 1万个单词,hi world" }

hello world 在整个index中出现的次数是一样多的

doc1 更相关,title field更短

分析一个document是如何被匹配上的

GET /test_index/test_type/6/_explain
{
    "query": {
        "match": {
            "test_field": "test hello"
        }
    }
}

 

Elasticsearch学习之相关度评分TF&IDF

标签:length   关联   font   计算   orm   inverse   mil   pre   算法   

原文地址:http://www.cnblogs.com/sunfie/p/7078974.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!