Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ElasticSearch: How do I delete index entries from head?

I want to delete index entries directly from MOBZ's ElasticSearch head (web UI).

I tried a DELETE query in the "Any Request" section with the following:

{"query":{"term":{"supplier":"ABC"}}}

However, all I get in return is:

{
ok: true
acknowledged: true
}

and the entries do not get deleted.

What am I doing wrong?

like image 931
cognito Avatar asked Mar 22 '13 18:03

cognito


People also ask

How do I delete a particular data index in Elasticsearch?

You use DELETE to remove a document from an index. You must specify the index name and document ID. You cannot send deletion requests directly to a data stream. To delete a document in a data stream, you must target the backing index containing the document.

How do I remove indices in Opensearch?

If you no longer need an index, you can use the delete index API operation to delete it.

How do I remove all files from elastic index?

Delete all documents from the indexwhen we pass “match_all”:{} then it will match all the documents so _delete_by_query will delete all the documents from the index.


2 Answers

You should have removed the "query" from your post data. You only need it for _search, and you should be using the _query entrypoint for delete. In that case it is obvious the post is only a query, thus making it redendant (and actually irrelevant) to explicitly state it's a query.

That is:

curl -XPOST 'localhost:9200/myindex/mydoc/_search' -d 
'{"query":{"term":{"supplier":"ABC"}}}'

will work fine for search. But to delete by query, if you try:

curl -XDELETE 'localhost:9200/myindex/mydoc/_query' -d 
'{"query":{"term":{"supplier":"ABC"}}}'

it won't work (note the change in entry point to _query, as well as switch CURL parameter to delete). You need to call:

curl -XDELETE 'localhost:9200/myindex/mydoc/_query' -d 
'{"term":{"supplier":"ABC"}}'

Let me know if this helps.

If you want to do it in HEAD:

  1. put /stock/one/_query in the any request text box next to the drop-box of "GET/PUT/POST/DELETE"

  2. choose DELETE in the drop-down menu

  3. the request body should be {"term":{"vendor":"Socks"}}

Your problem was that you used a request body of: {"query":{"term":{"vendor":"Socks"}}} That is fine for search, but not for delete.

like image 153
eran Avatar answered Sep 18 '22 23:09

eran


A simple way to delete from plugin head by doc Id:

  1. Go to Any Request TAB in plugin head
  2. Simply put http:/localhost:9200/myindex/indextype/id in the text box above DELETE drop-down
  3. Select DELETE from drop-down
  4. Execute the request by clicking in Request button

Here is the sample image:

like image 20
Muhammad Mujtaba Avatar answered Sep 19 '22 23:09

Muhammad Mujtaba