Segment Merge query

So I've been working on Elasticsearch for nearly two years now, and I love it :relieved: I've a question regarding the underlying mechanism during a merge.

When two segments S1 and S2 are merged together, the data from S1 and S2 are written to a new segment S3 and S1 and S2 are then discarded.

So my question is, the data transferred into S3, is it like a copy of data from S1 and S2 (meaning like the inverted index, stored fields, doc values, etc are copied) ?? Or is it like the _source from S1 and S2 are used to "reindex" data internally to S3 ?? :thinking:

It's more the former, not a reindex.

I don't know the low level "how" of it though, maybe one of the core team can point you to the code if you are really interested :slight_smile:

Yeah any of that information would be great :slight_smile: