Delete from read indexes

Hello,
I have a current write index and multiple read indexes .Is it possible to delete the documents from only the read indexes? Document with same ID will be present in both read and write index but I want the document to be deleted only from read index.

Thanks

Yes. If you are referring to ILM then the underlying indices are still standard Elasticsearch indices and can be manipulated.

It sounds like you want to delete from all indices in the index pattern except the one pointed to by the write alias. Is that correct? If so, that is as Mark pointed out possible but I do not think there is any easy way of addressing just these indices so you probably need a two stage process to find out which indices are to be deleted from and then list these explicitly.

It should be as easy as index-pattern-0*, as the alias is likely going to be index-pattern and all the underlying indices will have numbers preceding them.

That's assuming the defaults though.

That would however include the index currently being written to and not just the read indices.

Yeah, good point!

It might help if you described your use case. Maybe ILM with rollover is not the best fit for your requirements if you need to update documents and maintain only a single copy.

@Christian_Dahlqvist the use case here is as soon as I update the document in the write index ,I no longer need the other documents with the same ID which are present in read index, because when I try to get the documents I need the latest one, so I want to delete the documents in read index asynchronously, basically deletion of documents in read index should happen as a post process of updating a document in write index

What drove the decision to use rollover? How much data do you have? How is this expected to grow over time? What are your requirements around retention? How frequently are documents updated?

1 Like

Once a document is updated I no longer need the older ones , Documents will be updated very frequently so when I try to get I just need the latest one, I don't need multiple documents with the same ID

Then using ILM for this doesn't make any sense.
Use a single index and then just update the existing document.

1 Like

Thanks @warkolm @Christian_Dahlqvist

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