文档 index 到Lucene中时,会生成 segment。document nubmer从0开始,每索引一篇文档到segment里面,document nubmer加1.segment内document number是唯一的。
Internally, Lucene refers to documents by an integer document number. The first document added to an index is numbered zero, and each subsequent document added gets a number one greater than the previous.
而es中的 _id 只是ES 用来:get/delete 文档时 使用的一个id,与Lucene中的Document Number没有关系:
Most search applications using Apache Lucene assign a unique id, or primary key, to each indexed document. While Lucene itself does not require this (it could care less!), the application usually needs it to later replace, delete or retrieve that one document by its external id
参考:choosing-fast-unique-identifier-uuid
本文来自:Elastic 中文社区
感谢作者:Elastic 中文社区
查看原文:es里的document的"_id"和org.apache.lucene.search.ScoreDoc.doc是什么关系