首页 > IT职业 > IT生活 > 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是非常适合存索引的,在处理数据上也有些许适应,大家感兴趣的话,可以按照上述提供的内容,详细做了解学习。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/3598/viewspace-2831124/ ,如需转载,请注明出处,否则将追究法律责任。