为什么弹性材料中的文件是不可变的? [英] Why are documents in elasticsearch immutable?
问题描述
他们提到更新API每次更新文档中的某些东西时,都会执行一个检索更改重新索引循环
。我完全可以这样做,因为他们说文件是不可变的(见此)。我在这里质疑的是为什么它首先是不可变的。不会有一个优势,允许只是一个特定字段的更新和索引没有这是约束?
首先,告诉段落是不可变的,而不是告诉文件是不可变的。了解原因你需要了解lucene如何运作。卢塞恩是一个java库,其中建立了弹性搜索。在引擎盖下,单个分片是一个lucene实例,它执行文档存储和搜索的实际工作。 Elasticsearch更多是基于lucene的基于分布式REST的服务器层。
在lucene中,为了实现高索引速度,我们有段架构。一堆文件保存在一个段中,每个段是磁盘中的单个文件。由于写入操作之间的文件非常重,所以段被变为不可变的,以便所有后续写入都转到新段。
I am trying to get a hang of elasticsearch. Was reading through the definitive guide.
They've mentioned that the update API does a retrieve-change-reindex cycle each time I update something in a document. And I completely get that this is done because they say that "Documents are immutable"(see this). What I am questioning here is why have it immutable in the first place. Wouldn't there be an advantage of allowing update and index of just a particular field hadn't this been the constraint?
First , it's better to tell segments are immutable than telling documents are immutable. To understand the reason. You need to understand how lucene works. Lucerne is a java library on top of which elasticsearch is build. Under the hood a single shard is a lucene instance and it does the actual work of documents storage and search . Elasticsearch is more of a distributed REST based server layer on top of lucene.
In lucene in order to achieve high Indexing speed we have segment architecture. A bunch of files are kept in a segment where each segment is a single file in the disk. As file in between write operation is very heavy , a segment is made immutable so that all subsequent writes go to New segments.
这篇关于为什么弹性材料中的文件是不可变的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!