官网:https://elasticsearch-py.readthedocs.io/en/master/api.html

官网:https://github.com/elastic/elasticsearch-py/tree/master/elasticsearch/client

官网: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')
# 结果转换为字典
es_r_dict = es_r_object.execute().to_dict()

 

相关文章:

  • 2021-06-20
  • 2021-05-15
  • 2021-10-26
  • 2022-01-01
  • 2021-09-03
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-06
  • 2022-01-02
  • 2022-02-15
  • 2022-12-23
  • 2021-06-26
  • 2021-10-19
  • 2022-12-23
相关资源
相似解决方案