Delete


#1

How the heck do I delete records form an index?
index: test_index

This is not working:

DELETE test_index/myType
{
  "query":{
    "match_all": {
      
    }
  }
}

(David Pilato) #2

Why not deleting the index in that case?


#3

I find that I have to fool around with the previously made dashboards + visualizations.
Whenever I delete the whole index, those items become buggy, no data, errors, etc..

I tried to wait for the data to become available after re-indexing, but after a few minutes, I get impatient.


#4

This works:

https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html

POST my_index/_delete_by_query
{
  "query":{
    "match_all": {}
  }
}

(David Pilato) #5

This is really not efficient.

DELETE index

Is much much much better.


#6

Explain, please.


(David Pilato) #7

The delete by query will have to write new segments telling Lucene that docs X,Y,Z have been removed. Well, all docs basically.
Then at some point a merge segments operation will happen and those files will be removed.

Look at the disk space, then try the delete by query and just after, look at the disk space.

Removing an index will immediately remove all files "like a rm -r". No merge of segments. Space is immediately released.


#8

Gotcha!

I decided to go with automating the workflow.

  1. Delete Index
  2. Reload Index with Mapping in an external file (easier than writing in code)
  3. Reload data

(David Pilato) #9

Definitely better. Note that you can use aliases so your users won't ever notice that you reindexed.


(system) #10

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