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

DELETE FROM [Index]

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

   http://localhost:9200/[indexName]

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


当前回答

删除所有索引的python脚本:

import requests
import json

ES_HOST = "http://localhost:9200"
ES_URL = f"{ES_HOST}/_cat/indices?format=json"

indexes = requests.get(ES_URL).content
indexes = json.loads(index.decode())

for i in index:
    index_name = i['index']
    content = requests.delete(f"{ES_HOST}/{index_name}").content
    print(content)

其他回答

您可以删除一个或多个索引,这实际上是从磁盘删除它们的文件。例如:

curl -XDELETE localhost:9200/$INDEXNAME

其中$INDEXNAME可以是索引名(例如users_v2), N个用逗号分隔的索引(例如users_v2,users_v3)。索引模式(例如users_*)或_all也可以,除非它在配置中通过action.destructive_requires_name: true被阻止。

删除单个文档是可能的,但这不会立即清除它们。删除只是一种软删除,在段合并过程中真正删除文档。在这个演讲中,你会发现很多关于分段和合并的细节。它是关于Solr的,但是合并来自Lucene,所以你在Elasticsearch中有相同的选项。

回到API,你可以通过ID删除单个文档(如果你使用路由索引,则提供路由值):

curl -XDELETE localhost:9200/users_v2/_doc/user1

或通过查询:

curl -XPOST -H 'Content-Type: application/json' localhost:9200/users_v2/_delete_by_query -d '{
  "query": {
    "match": {
      "description_field": "bad user"
    }
  }
}'

我想删除logstash索引,并搜索了很多关于不同的工具,如curl。但最后找到了解决方案。 登录到Kibana。进入开发工具选项卡,在查询字段中输入DELETE /logstash-*,然后点击绿色箭头按钮。如果你得到“acknowledge”:true作为响应,这意味着数据已经被清除。

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

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

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

你必须发送一个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/

好运!

最简单的方法!

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