当前位置:首页 > 日记本 > 正文内容

python删除Elasticsearch数据库

zhangchap1年前 (2023-03-29)日记本151
from elasticsearch import Elasticsearch

# 创建 Elasticsearch 客户端
es = Elasticsearch(['http://localhost:9200'])

# 要删除的索引名称
index_name = "articles"

# 判断索引是否存在
if es.indices.exists(index=index_name):
    # 删除索引
    es.indices.delete(index=index_name)
    print(f"Index '{index_name}' has been deleted.")
else:
    print(f"Index '{index_name}' does not exist.")


分享给朋友:

相关文章

火狐添加自定义搜索引擎

直接网址搜索自定义添加:https://mycroftproject.com/...

lxml win 安装方法

文档地址:https://lxml.de/installation.htmlwindows 下安装不了的都可以在这里找:https://www.lfd.uci.edu/~gohl...

python 函数 开启多线程示例

from threading import Thread def readfile(queue:Queue):    &nbs...

Python 正则表达式 带分组的替换 \g

import re re.sub(r'([^a-z]*)[a-z]([^a-z]*)', '\g<1>\g<2>',wor...

python md5生成

from hashlib import md5 md5_hash = md5(title.encode('utf-8')).hexd...

python下elasticsearch搜索接口介绍

# elasticsearch 默认算法bm25 from elasticsearch import Elasticsearch import&n...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。