Elasticsearch中的segment理解
来源:互联网 发布:win域名无法备案 编辑:程序博客网 时间:2024/06/05 10:44
在Elasticsearch中, 需要搞清楚几个名词,如segment/doc/term/token/shard/index等, 其实segment/doc/term/token都是lucene中的概念。这样有助于更深入的了解和使用ES。
document: 索引和搜索的主要数据载体,对应写入到ES中的一个doc。
field: document中的各个字段。
term: 词项,搜索时的一个单位,代表文本中的某个词。
token: 词条,词项(term)在字段(field)中的一次出现,包括词项的文本、开始和结束的位移、类型等信息。
Lucene内部使用的是倒排索引的数据结构, 将词项(term)映射到文档(document)。
例如:某3个文档,假设某个字段的文本如下
ElasticSearch Server (文档1)
Matering ElasticSearch (文档2)
Apache solr 4 Cookbook (文档3)
term次数doc id413Apache13Cookbook13ElasticSearch21,2Matering11Server11solr13index: 在ES中类似数据库中db
shard:
A "shard" is an instance of Lucene. It is a fully functional search engine in its own right. An "index" could consist of a single shard, but generally consists of several shards, to allow the index to grow and to be split over several machines.
A "primary shard" is the main home for a document. A "replica shard" is a copy of the primary shard that provides (1) failover in case the primary dies and (2) increased read throughput
segment:
Each shard contains multiple "segments", where a segment is an inverted index. A search in a shard will search each segment in turn, then combine their results into the final results for that shard.
While you are indexing documents, Elasticsearch collects them in memory (and in the transaction log, for safety) then every second or so, writes a new small segment to disk, and "refreshes" the search.
This makes the data in the new segment visible to search (ie they are "searchable"), but the segment has not been fsync'ed to disk, so is still at risk of data loss.
Every so often, Elasticsearch will "flush", which means fsync'ing the segments, (they are now "committed") and clearing out the transaction log, which is no longer needed because we know that the new data has been written to disk.
The more segments there are, the longer each search takes. So Elasticsearch will merge a number of segments of a similar size ("tier") into a single bigger segment, through a background merge process. Once the new bigger segment is written, the old segments are dropped. This process is repeated on the bigger segments when there are too many of the same size.
Segments are immutable. When a document is updated, it actually just marks the old document as deleted, and indexes a new document. The merge process also expunges these old deleted documents.
参考:
https://www.elastic.co/guide/en/elasticsearch/reference/current/glossary.html
http://stackoverflow.com/questions/15426441/understanding-segments-in-elasticsearch
- Elasticsearch中的segment理解
- Elasticsearch 的 Shard 和 Segment
- Elasticsearch 的 Shard 和 Segment
- 第十二篇 elasticsearch中的mapping透彻理解
- segment fault 理解
- block/extent/segment的理解
- Elasticsearch store属性理解
- Elasticsearch 理解重点
- ElasticSearch个人理解
- Elasticsearch深入理解(一)
- elasticsearch重要概念理解
- segment
- Segment
- Segment
- Segment
- Segment
- segment
- elasticsearch中的mapping简介
- 什么是SVG和SVG常用的形状
- jsp获取路径方法
- 在mac上从外置硬盘启动windows教程
- HTML第二章框架
- 第七周-闰年
- Elasticsearch中的segment理解
- CFGym 100803DSpace Golf+物理(数学)计算
- xcode8 更新内容整理
- 关于二进制序列的两道典型例题(位运算符)
- BottomBar中如何动态替换图片显示
- 并查集详解 (转)
- Android性能优化典范(四)
- 从一个activity回退到另一个activity并返回值
- HTML第二章网页的跳转