标签:shard source 创建失败 elastics stp highlight 模块 结果 resource
命令如下
from elasticsearch import Elasticsearch es = Elasticsearch([{"host":"10.87.6.3","port":9200},]) s = "test" + "python" try: ret = es.indices.create(index=s) except Exception as e: print(e) else: print("创建成果") print(ret)
返回的结果如下,证明创建成果
{‘acknowledged‘: True, ‘shards_acknowledged‘: True, ‘index‘: ‘testpython‘}
返回的结果如下,证明创建失败
RequestError(400, ‘resource_already_exists_exception‘, ‘index [testpython/yEzYUZEiTjaZWxtN0RM_Uw] already exists‘)
代码如下
try: ret = es.indices.delete(index=s) except Exception as e: print(e) else: print("删除成果") print(ret)
返回结果,证明删除成果
{‘acknowledged‘: True}
返回结果,证明删除失败
NotFoundError(404, ‘index_not_found_exception‘, ‘no such index‘)
python使用elasticsearch模块操作elasticsearch
标签:shard source 创建失败 elastics stp highlight 模块 结果 resource
原文地址:https://www.cnblogs.com/bainianminguo/p/10419848.html