我刚打酱油去了,不好意思

<ElasticSearch源码解读>关于提供id导致索引速度下降的疑问

Elasticsearch | 作者 yuechen323 | 发布于2019年05月08日 | 阅读数:1594

原文如下: 索引过程调整和优化
自动生成 doc ID
如果外部指定了 id, ES 先尝试读取 doc 原来的版本号, 判断是否需要更新, 涉及一次磁盘的读取, 通过自动生成可以避免这个环节
 
我的疑问是: 
那么如果不指定 id 的话, 在 es 插入索引后, 将返回给我们的 ID, update 到相应的数据库表中
如果不这么那么下次 update/delete 索引是无法操作的, 因为 update/delete 都是通过 id 来进行的
 
大家有没有好的方法呢?  不想加这个字段到表中
已邀请:

rochy - rochy_he

赞同来自:

推荐使用指定 ID 的方法,插入性能没有多大损失,你可以自己测试一下看一下差距,一般是可以忽略的

Ombres

赞同来自:

主要看业务,一般来说你有自己的id就用自己的id吧

laoyang360 - 《一本书讲透Elasticsearch》作者,Elastic认证工程师 [死磕Elasitcsearch]知识星球地址:http://t.cn/RmwM3N9;微信公众号:铭毅天下; 博客:https://elastic.blog.csdn.net

赞同来自:

官网已经给出了答案:

如果使用了自动生成id,每次导入数据的时候都要进行id的检查。这里是有性能消耗的。

但是使用随机生成id,就不需要这一步。

所以推荐使用,随机生成的ID,系统自带的。
Use auto-generated ids

When indexing a document that has an explicit id, Elasticsearch needs to check whether a document with the same id already exists within the same shard, which is a costly operation and gets even more costly as the index grows. By using auto-generated ids, Elasticsearch can skip this check, which makes indexing faster.

zqc0512 - andy zhou

赞同来自:

你自己再自定义一个字段吧,来做与业务系统关联的ID,不要用默认带的这个_id.

要回复问题请先登录注册