发布时间:2019-09-10 09:20:43编辑:auto阅读(2077)
环境 : pyhton3
加载模块
from elasticsearch import Elasticsearch
连接ES
es = Elasticsearch(["172.30.6.12"])
查询
res = es.search(index="test-index", body={"query":{"match_all":{}}}) # 注 index 后面的是索引的名字
# 查询请求主机是ai.baidu.com 所有信息
res = es.search(index="packetbeat-*", body={'query':{'match':{'http.request.headers.host':'ai.baidu.com'}}})
res = es.search(index="test-index", body={'query':{'match':{'any':'data'}}}) #获取any=data的所有值参考链接:https://www.cnblogs.com/yxpblog/p/5141738.html
忽略400,404
es.indices.delete(index='test-index', ignore=[400, 404])
过滤
res=es.search(index='packetbeat-*', filter_path=['hits.hits._source'])

上一篇: Python输出文件的内容
下一篇: python面向对象OOP入门
51201
50620
41242
38058
32520
29427
28289
23146
23101
21440
1496°
2209°
1834°
1766°
2072°
1824°
2507°
4207°
4068°
2908°