Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete unassigned shards in elasticsearch?

I have only one node on one computer and the index have 5 shards without replicas. Here are some parameters describe my elasticsearch node(healthy indexes are ignored in the following list):

GET /_cat/indices?v
health status index   pri rep docs.count docs.deleted store.size pri.store.size 
red    open   datas     5   0  344999414            0     43.9gb         43.9gb 

GET _cat/shards                                    
datas   4 p STARTED    114991132 14.6gb 127.0.0.1 Eric the Red 
datas   3 p STARTED    114995287 14.6gb 127.0.0.1 Eric the Red 
datas   2 p STARTED    115012995 14.6gb 127.0.0.1 Eric the Red 
datas   1 p UNASSIGNED                                         
datas   0 p UNASSIGNED                  

shards disk.indices disk.used disk.avail disk.total disk.percent host      ip        node         
14       65.9gb     710gb    202.8gb    912.8gb           77 127.0.0.1 127.0.0.1 Eric the Red 
 3                                                                               UNASSIGNED   
like image 763
Allen Avatar asked May 25 '16 08:05

Allen


People also ask

How do I reduce number of shards in Elasticsearch?

If you're using time-based index names, for example daily indices for logging, and you don't have enough data, a good way to reduce the number of shards would be to switch to a weekly or a monthly pattern. You can also group old read-only indices., by month, quarter or year.


1 Answers

Although deleting created shards doesn't seem to be supported, as mentioned on the comments above, reducing the number of replicas to zero for the indexes with UNASSIGNED shards might do the job, at least for single node clusters.

PUT /{my_index}/_settings
{
   "index" : {
       "number_of_replicas" : 0
   }
}

reference

like image 98
Zedzdead Avatar answered Nov 08 '22 13:11

Zedzdead