Delete Document on Elasticsearch

Sometimes we made a mistake on document that we uploaded to Elasticsearch. It is probably possible to update the document with a new one. However, deleting the documents are probably a better and cleaner option.

To do that on Elasticsearch, we can execute the query below,
curl -X POST "localhost:9200/twitter/_delete_by_query?scroll_size=5000" -H 'Content-Type: application/json' -d'
{
  "query": {
    "term": {
      "user": "kimchy"
    }
  }
}
'

Scross_size may be required because otherwise It would only delete 1000 documents.


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

Comments