为什么elasticsearch中的文档是不可变的? [英] Why are documents in elasticsearch immutable?

查看:95
本文介绍了为什么elasticsearch中的文档是不可变的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 elasticsearch.正在阅读权威指南.

I am trying to get a hang of elasticsearch. Was reading through the definitive guide.

他们提到更新 API 执行检索-更改-重新索引循环每次我更新文档中的内容时.我完全明白这是因为他们说文档是不可变的"(参见 这个).我在这里质疑的是为什么一开始就让它不可变.如果没有这个限制,允许只更新和索引特定字段难道不是一个优势吗?

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?

推荐答案

首先,告诉段不可变比告诉文档不可变更好.要了解原因.您需要了解 lucene 的工作原理.Lucerne 是一个 Java 库,elasticsearch 建立在它之上.在幕后,单个分片是一个 lucene 实例,它执行文档存储和搜索的实际工作.Elasticsearch 更像是一个基于 lucene 的分布式 REST 服务器层.

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 built. 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.

在 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.

这篇关于为什么elasticsearch中的文档是不可变的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆