python中elasticsearch是什么?

346次阅读
没有评论

python中elasticsearch是什么? 

本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。

安装库:

pip install elasticsearch

引入库:

from elasticsearch import ElasticSearch
es = ElasticSearch(['localhost:9200'])

创建索引:

es.indices.create(index='project', ignore=400)

删除索引:

es.indices.delete(index='project', ignore_unavailable=True)

插入数据:

for i in range(10):
    body = {
        'name': '张三' % i,
        'age': 20 + i,
        'desc': '我是张家的老' % i
    }
    es.create(index='project', doc_type='_doc', body=body, id=i)

elasticsearch是非常适合存索引的,在处理数据上也有些许适应,大家感兴趣的话,可以按照上述提供的内容,详细做了解学习。

神龙|纯净稳定代理IP免费测试>>>>>>>>天启|企业级代理IP免费测试>>>>>>>>IPIPGO|全球住宅代理IP免费测试

相关文章:

版权声明:wuyou2021-07-15发表,共计611字。
新手QQ群:570568346,欢迎进群讨论 Python51学习