Python创建ES索引,,# pip inst
Python创建ES索引,,# pip inst
# pip install elasticsearchfrom datetime import datetimefrom elasticsearch import Elasticsearches_servers = [{ "host": "10.10.6.225", "port": "9200"}]es = Elasticsearch(es_servers)doc = { ‘author‘: ‘kimchy‘, ‘text‘: ‘Elasticsearch: cool. bonsai cool.‘, ‘timestamp‘: datetime.now(),}res = es.index(index="test-index", doc_type=‘tweet‘, id=1, body=doc)print(res)res = es.get(index="test-index", doc_type=‘tweet‘, id=1)print(res[‘_source‘])es.indices.refresh(index="test-index")res = es.search(index="test-index", body={"query": {"match_all": {}}})print("Got %d Hits:" % res[‘hits‘][‘total‘])for hit in res[‘hits‘][‘hits‘]: print("%(timestamp)s %(author)s: %(text)s" % hit["_source"])
Python创建ES索引
相关内容
- Python3+RobotFramewok 用户自定义库的开发(四),, 在
- 学习记录001-接口了解/请求and抓包and基础的python,001-
- 十一.python面向对象(接口),.python面向对象,一. 接口接口
- 乐搏讲自动化测试 - Python基本数据类型(11),,数据类
- 《python语言设计程序设计》_第一章编程题,,题目1.1 :
- python zip函数小结,,zip()函数用于将
- python学习笔记——multiprocess 多进程组件Pool,pythonmult
- 使用vim打造自己的python编辑器,,基础配置vim的配置
- python生成四位随机数,python四位随机数,有些时候需要发
- 莫烦Python之机器学习概念了解,烦python机器概念,1、机
评论关闭