ES 搜索算法

2020-02-28

布爾模型

在查詢中使用 AND 、 OR 和 NOT

TF/IDF

tf(t in d) = √frequency

詞 t 在文檔 d 的詞頻( tf )是該詞在文檔中出現(xiàn)次數(shù)的平方根。

將參數(shù) index_options 設(shè)置為 docs 可以禁用詞頻統(tǒng)計及詞頻位置,這個映射的字段不會計算詞的出現(xiàn)次數(shù),對于短語或近似查詢也不可用。要求精確查詢的 not_analyzed 字符串字段會默認使用該設(shè)置。

idf(t) = 1 + log ( numDocs / (docFreq + 1))

詞 t 的逆向文檔頻率( idf )是:索引中文檔數(shù)量除以所有包含該詞的文檔數(shù),然后求其對數(shù)。

字段長度歸一值

norm(d) = 1 / √numTerms

norm是字段中詞數(shù)平方根的倒數(shù)

舉例

example

vector space model

when search 'happy hippopotamus':

// of course 'hippopotamus' weighs more
happy hippopotamus => [2,5] (weight vectors)

then calculated in indices:

Document 1: (happy,____________)—[2,0]
Document 2: ( ___ ,hippopotamus)—[0,5]
Document 3: (happy,hippopotamus)—[2,5]

It appears that doc 3 is the most relevant one.


image.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容