Why lucene index files are deleted when document is inserted/updated?

Hi All,

Elasticsearch - 5.4.3

I'm updating a document by using the command:

curl -X POST "node1:9200/index1/external/1/_update?pretty" -H 'Content-Type: application/json' -d'

{
"doc": { "name": "Elastic" }
}'

When a document is updated, it is observed that first the data is inserted in the index and then in the lucene index files (such as _1.cfs, _1_Lucene50_0.doc, _1_Lucene50_0.tim, _1_Lucene54_0.dvd, etc. ) successfully using write system call.

For eg.

write fd=171(/var/lib/elasticsearch/nodes/0/indices/fxXTEfKZScmU7emMgJg01Q/3/index/_1_Lucene54_0.dvd) size=84

After writing the lucene files and all the files are closed.

But after closing all the files, these files are deleted using the unlink systemcall.
For eg.

unlink res=0 path=/var/lib/elasticsearch/nodes/0/indices/fxXTEfKZScmU7emMgJg01Q/3/index/_1_Lucene54_0.dvd

When a GET API command is executed to get the updated document, it is observed that the document is fetched successfully.

Can anyone explain why elasticsearch deletes all the lucene index files after inserting data in them?

Note: This same behaviour is observed when the document is inserted in the elasticsearch

Regards
Nikhil Kapoor

All Lucerne segments are immutable, and are merged as data is indexed/updated. Once no longer in use following a merge, they are deleted.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.