我想从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。

其他回答

这里有很多很好的答案,但我也想补充一点:

如果你在AWS ElasticSearch服务上运行,你不能删除/删除索引。不是删除索引,而是必须重新索引它们。

您可以删除整个索引,文档类型或一个特定的id数据。 这是三种方法:

curl -XDELETE localhost:9200/index_name curl -XDELETE localhost:9200/index_name/doc-type curl -XDELETE localhost:9200/index_name/doc-type/ documententid

如果你想删除所有索引,那么使用通配符。

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

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/

最简单的方法!

Endpoint :
http://localhost:9201/twitter/_delete_by_query

Payload :
{
  "query": { 
    "match": {
      "message": "some message"
    }
  }
}

在弹性搜索中,twitter在哪里是索引

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

对于批量按查询删除,你可以使用特殊的按查询删除API:

$ curl -XDELETE 'http://localhost:9200/twitter/tweet/_query' -d '{
    "query" : {
        "term" : { "user" : "kimchy" }
    }
}

在历史上,该API被删除,然后又重新引入

谁有趣,它有悠久的历史。

在这个答案的第一个版本中,我参考了elasticsearch版本1.6的文档。在这篇文章中,该功能被标记为已弃用,但运行良好。 在elasticsearch 2.0版本中,它被移动到单独的插件中。甚至解释了为什么它成为插件的原因。 它再次出现在5.0版的核心API中!