首页IT科技python elasticsearch_dsl(python中elasticsearch是什么?)

python elasticsearch_dsl(python中elasticsearch是什么?)

时间2025-07-31 17:22:27分类IT科技浏览5462
导读:本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。...

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

安装库:

pipinstallelasticsearch

引入库:

fromelasticsearchimportElasticSearch es=ElasticSearch([localhost:9200])

创建索引:

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

删除索引:

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

插入数据:

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

创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!

展开全文READ MORE
python的remove用法(Python的errno模块有何用法?) python写多线程(python多线程如何自定义线程类?)