倒排索引
https://codingexplained.com/coding/elasticsearch/understanding-the-inverted-index-in-elasticsearch
定义:
对数据分析, 拆分出数据中的词条(keyword), 以词条作为key, 对应的数据存储位置作为value, 实现索引的存储。这种索引称为倒排索引(revested index) , 倒排索引是Document 写入ElasticSearch 时分析维护的。
给我们查字典的部首索引是一个概念。根据偏旁可以定位到页码(存储位置)
例子:
如下面的汽车表
key | model | desc |
---|---|---|
1 | Audi R8 | luxury high-performance sports car |
2 | BMW 730I | luxury business car |
3 | BMW 530 | luxury family car |
ES 可以对Model 和 DESC(实际上就是两个Document的字段), 都进行词条拆分, 拆分如下:
keywords | data |
---|---|
car | 1,2,3 |
BMW | 2,3 |
luxury | 1,2,3 |
business | 2 |
sports | 1 |
family | 3 |
实际上, 我们对ES的搜索肯定是基于某个字段的条件的, 然后我们就可以根据上面的keyword 和 存储位置的mapping快速找到对应的数据。
但是词条具体是怎么拆的, 用的什么拆词器, 在深入了解ES的时候才会接触到。