我想从ElasticSearch中删除数据。我已经删除了索引。然而,这似乎并没有真正删除数据本身。我看到的其他东西指向通过查询删除功能。然而,我甚至不知道该问什么。我知道指数。本质上,我想知道如何做a

DELETE FROM [Index]

从邮递员在Chrome。然而,我没有任何运气。似乎无论我做什么,数据都不会消失。到目前为止,我已经成功地删除索引使用DELETE HTTP动词在邮差和使用一个url:

   http://localhost:9200/[indexName]

然而,这似乎并没有真正删除数据(又名文档)本身。


当前回答

你可以试试这个卷发:

curl --location --request DELETE 'http://<username>:<password>@<url>:9200/<index name>/<doc type>/<document id>

或者如果你不想在URL上设置用户名和密码,那么也可以尝试这个curl:

curl --location --request DELETE 'http://<url>:9200/<index name>/<doc type>/<document id>' --header 'Authorization: Basic <Base64 encoded username:password>'

执行后,响应体将包含一个结果字段。如果该字段的值被删除,则意味着文档删除成功。

在这个curl中,我假设您已经将您的elastic配置为使用http。如果您正在使用https,只需将协议更改为https。

其他回答

你必须发送一个DELETE请求到

http://[your_host]:9200/[your_index_name_here]

你也可以删除单个文档:

http://[your_host]:9200/[your_index_name_here]/[your_type_here]/[your_doc_id]

我建议你用橡皮筋。

删除后,您可以使用以下URL查看索引是否仍然存在:http://[your_host]:9200/_stats/

好运!

在python中可以这样删除索引

from elasticsearch import Elasticsearch

es = Elasticsearch([{'host':'localhost', 'port':'9200'}])

es.index(index='grades',doc_type='ist_samester',id=1,body={
    "Name":"Programming Fundamentals",
    "Grade":"A"
})

es.indices.delete(index='grades')
#list all index:       curl -XGET http://localhost:9200/_cat/indices?v 

#delete index:         curl -XDELETE 'localhost:9200/index_name'
#delete all indices:   curl -XDELETE 'localhost:9200/_all'
#delete document   :   curl -XDELETE 'localhost:9200/index_name/type_name/document_id'

安装kibana。Kibana有一个更智能的开发工具,可以帮助您轻松地构建查询。

如果你需要删除所有索引,这可能会派上用场:

curl -X DELETE 'http://localhost:9200/_all'

Powershell:

Invoke-WebRequest -method DELETE http://localhost:9200/_all

删除索引将同时删除映射和类型。可以通过以下查询删除所有行

curl -XDELETE 'localhost:9200/twitter/tweet/_query?pretty' -d'
{
   "query": { 
      "match_all": 
   }
}'

然而,对于上述查询,您需要安装Elasticsearch的2.0.0-beta1删除查询删除插件

Install delete-by-query plugin

sudo bin/plugin install delete-by-query

更多的

http://blog.appliedinformaticsinc.com/how-to-delete-elasticsearch-data-records-by-dsl-query/