0

elasticsearch倒排索引

 2 years ago
source link: https://wakzz.cn/2018/09/09/elasticsearch/%E5%80%92%E6%8E%92%E7%B4%A2%E5%BC%95/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

elasticsearch倒排索引

祈雨的博客
2018-09-09

Elasticsearch使用一种称为倒排索引的结构,它适用于快速的全文搜索。一个倒排索引由文档中所有不重复词的列表构成,对于其中每个词,有一个包含它的文档列表。

当Elasticsearch储存如下的几条数据时,数据会被分词拆分。

  1. my name is tom.
  2. tom comes from English.

词 id

my 1

name 1

is 1

tom 1,2

comes 2

from 2

English 2

此时,当用户搜索tom English时,搜索词被分词为tomEnglish,对比如上表格tom将匹配到数据1和数据2,English将匹配到数据2。两条数据都匹配,但是数据2的匹配度高于数据1,因此数据2的_score将高于数据1。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK