elasticsearchdocuments

Delete documents of type in Elasticsearch


I want to delete all the documents indexed within a type in Elasticsearch, using the HTTP/REST api, but I don't want to delete the mapping for this type

How can I build the query in the URL to do this?


Solution

  • Before executing command, index/mapping state; (screenshots taken from elasticsearch head plugin web interface)

    enter image description here

    enter image description here

    enter image description here

    Command;

    curl -XDELETE 'http://localhost:9200/publishercategoryeu/autocomplete/_query' -d '
    {
      "query": {
        "bool": {
          "must": [
            {
              "match_all": {}
            }
          ]
        }
      }
    }
    '
    

    Result;

    enter image description here

    After executing command, index/mapping state;

    enter image description here

    enter image description here

    enter image description here

    As we can see we deleted all the documents indexed within a type(mapping) without delete index or type(mapping).