pythonelasticsearch模块使用-创新互联
环境 : 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'])

创新互联www.cdcxhl.cn,专业提供香港、美国云服务器,动态BGP最优骨干路由自动选择,持续稳定高效的网络助力业务部署。公司持有工信部办法的idc、isp许可证, 机房独有T级流量清洗系统配攻击溯源,准确进行流量调度,确保服务器高可用性。佳节活动现已开启,新人活动云服务器买多久送多久。
本文题目:pythonelasticsearch模块使用-创新互联
文章起源:http://www.jxjierui.cn/article/djjhgh.html


咨询
建站咨询
