【Python】Elasticsearch和elasticsearch_dsl
生活随笔
收集整理的這篇文章主要介紹了
【Python】Elasticsearch和elasticsearch_dsl
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
【Python】Elasticsearch和elasticsearch_dsl
官網(wǎng):https://elasticsearch-py.readthedocs.io/en/master/api.html
官網(wǎng):https://github.com/elastic/elasticsearch-py/tree/master/elasticsearch/client
官網(wǎng):https://elasticsearch-dsl.readthedocs.io/en/latest/api.html
?
from elasticsearch_dsl import connections, Search from elasticsearch import Elasticsearch from elasticsearch.exceptions import *es_object = Elasticsearch(['url:9200'], sniffer_timeout=60, timeout=30) # 獲取es中所有的索引 # 返回類型為字典,只返回索引名 es_object.cat.indices(format='json',h='index') # 查詢多個索引 es_s_object = Search(using = es_object, index = ['log-2018-07-31','log-2018-07-30','log-2018-07-29']) # 查詢一個索引 es_s_object = Search(using = es_object, index = 'log-2018-07-31') # 條件查詢1 es_r_object = es_s_object.filter("range", timestamp={"gte": 1532879975, "lt":1532880095}) # 條件查詢2 es_r_object = es_r_object.filter("term", title = '12345') # 結(jié)果轉(zhuǎn)換為字典 es_r_dict = es_r_object.execute().to_dict()?
posted on 2018-07-31 17:07 poorX 閱讀(...) 評論(...) 編輯 收藏轉(zhuǎn)載于:https://www.cnblogs.com/jiangxu67/p/9396949.html
總結(jié)
以上是生活随笔為你收集整理的【Python】Elasticsearch和elasticsearch_dsl的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【设计模式】【行为型模式】模板模式
- 下一篇: 使用python简单连接并操作数据库