Deleting ElasticSearch Data Directory

If I just delete the directory in which the data is stored, restart Elasticsearch, it should recreate that directory and populate it with new data according to the config, correct?

I have unassigned shards, but would just like to start from scratch. Is this the best way to do it?

Hello @Andrew_Tillotson if what you're trying to do is just to sort out the unassigned shards deleting the data directory and start from scratch is not the best option at all.

First check in which of your nodes are the unassigned shards:

GET _cat/shards/your_index
GET _cat/allocation/explain

This two requets will output where you unassigned shards are and the reason why they remain like that.

I understand its not the best option, but the data in the system isn't what we'll be using - just test stuff.

I just wanted to make sure I wasn't creating a bigger headache by deleting the directory and letting it rebuild.

@Andrew_Tillotson If you proceed your cluster will be empty. Indices, templates, visualization/dashboards, user/roles, machine learning jobs, etcetera will be all gone.

well I don't want to lose all of that.. I'll check out the shards. I can delete specific unallocated shards and not lose the rest, correct?

Thanks again for the help.

Not sure about how to delete unassigned shards, can you share your index settings and the output of the previously 2 requests?

You can update the index settings for proper allocation, this usually solves the problem.

Welcome to our community! :smiley:

Please don't do this, it's not supported and likely will cause Elasticsearch to break.
Make sure you always use the APIs to delete data.

1 Like

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