0

I have an single Elasticsearch index which has maximum number of documents. i want to delete some data from this index. i have tried running a delete_by_query but it fails. any sugestions for this, which i would able to keep the index and its data and also delete some old data from the same index ?

This is the request i was running.

curl -X GET "1localhost:9200/produdtion-index/_search?pretty" -H 'Content-Type: application/json' -d'
{
  "query": {
                    "bool": {
                        "must": [
                            { "range": { "submitDate": { "lte": "20200421" } } }   
                        ]
                    }
                }
}
' 
12
  • 1
    What error do you get? Something like "maximum documents per shard reached"? Commented Jul 24, 2020 at 13:11
  • 1
    If you're missing storage space, it's very hard to get around those issues. You should plan your storage space according to your needs before indexing your data. Now, you should increase your storage space if you want to go forward Commented Jul 24, 2020 at 13:44
  • 1
    Deleting documents doesn't reclaim the space immediately, that just marks the document deleted in the underlying segment files, so that wouldn't solve your issue in the short term. What you can try to do is to forcemerge the index, but if you're missing space, it might not work out as the process will require additional space to rewrite the segments without the deleted documents. Commented Jul 24, 2020 at 13:50
  • 1
    it just means that the forcemerge call ran successfully, not much more. Do you see some reclaimed space? Commented Jul 27, 2020 at 15:47
  • 1
    As I said, calling forcemerge is bandaid, you need to provision enough disk space prior to indexing data. Now your best option is to increase disk space (storage is cheap) Commented Jul 27, 2020 at 16:08

1 Answer 1

1

Try index life cycle managementhttps://www.elastic.co/guide/en/elasticsearch/reference/current/index-lifecycle-management.html You can split the index based on the number of documents and then delete them

Sign up to request clarification or add additional context in comments.

1 Comment

Thank You mate. not the solution for my problem but it helped me to find the re-index api.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.