Groups bulk request items by shard, optionally creating non-existent indices and delegates to link TransportShardBulkAction for shard-level bulk execution
if you are tempted to use IndexReader for deletion,remember that Lucene allows only one writer to be open at once. Confusingly, an IndexReader that's performing deletes count as a "writer". This means you are forced to close any open IndexWriter before doing deletions with IndexReader and vice versa.
2 个回复
zqc0512 - andy zhou
赞同来自:
还有就是现在集群压力是不是很大 cerebro 看下。
hapjin
赞同来自:
index操作对应的Action是org.elasticsearch.action.index.TransportIndexAction,看里面注释说是:已经用TransportBulkAction来表示index操作了。
TransportBulkAction里面有个TransportShardBulkAction类型的实例变量,批量操作其实就是代理给TransportShardBulkAction执行的:
TransportShardBulkAction 所代表的批量操作用的线程池是:ThreadPool.Names.WRITE 所以我觉得有可能:bulk delete 和 bulk indexing 共用了线程池了,如果是共用线程池的话,那么bulk delete 影响bulk index 就很好理解了。(具体逻辑还得再理一下),可参考:org.elasticsearch.threadpool.ThreadPool#ThreadPool
2,delete触发 translog刷新和refresh segment角度
虽然:org.elasticsearch.index.engine.InternalEngine#delete里面说delete-by-id不会触发生成新的segment,但是会应该会刷新translog的,而indexing也会刷新translog,所以二者有影响。
3,从底层Lucene上看:既可以通过IndexReader、也可以通过IndexWriter来删除文档,但对一个索引而言,任何时刻只能有一个打开的IndexWriter,当基于IndexReader来删除文档时,已打开的IndexWriter会被强制关闭。从而影响Lucene索引文档的速度。
额外补充一篇 删除文档 会影响 搜索的性能:lucenes-handling-of-deleted-documents
版本,ES6.3.2