[Elasticsearch - The Definitive Guide] Dynamically Updatable Indices

Elastic/TheDefinitiveGuide 2015. 12. 9. 16:25

Elasticsearch가 lucene 기반으로 만들어진 분산검색엔진 이라는 것은 이미 잘 알고 계실겁니다.

하지만 elasticsearch를 사용하시는 분들중 lucene을 잘 아시는 분들은 그렇게 많이 계시지는 않은것 같아 참고 할 만한 좋은 내용이 있어 올려 봅니다.


원문링크)

https://www.elastic.co/guide/en/elasticsearch/guide/current/dynamic-indices.html


원문 Snippet)

[Deletes and Updates]

Segments are immutable, so documents cannot be removed from older segments, nor can older segments be updated to reflect a newer version of a document. Instead, every commit point includes a .del file that lists which documents in which segments have been deleted.

When a document is “deleted,” it is actually just marked as deleted in the .del file. A document that has been marked as deleted can still match a query, but it is removed from the results list before the final query results are returned.

Document updates work in a similar way: when a document is updated, the old version of the document is marked as deleted, and the new version of the document is indexed in a new segment. Perhaps both versions of the document will match a query, but the older deleted version is removed before the query results are returned.


아래는 원문에 나와 있는 per-segment search works 간단 정리 입니다.

1) write in-memory buffer

2) write new segment file from in-memory buffer

3) write commit point (Refresh API on Elasticsearch)

4) flush in-memory buffer

5) searchable


※ 이 내용과 실제 elasticsearch 에서 primary shard 와 replica shard 간 데이터가 sync 되는 것과는 다른 내용입니다.

: