运行代码,
from elasticsearch import Elasticsearch
from elasticsearch_dsl import Search, Q, A
client = Elasticsearch(timeout=100)
s = Search(using=client, index="cms*")
s.aggs.bucket('ExitCode', 'terms', field='ExitCode').metric('avgCpuEff', 'avg', field='CpuEff')
for hit in s[0:20].execute():
print hit['ExitCode']
产生几个ExitCode = 0.我认为术语桶应该对具有相同退出代码的所有结果进行分组,在本例中。究竟发生了什么?
答案 0 :(得分:1)
您正在重复点击,您需要迭代聚合的存储桶:
response = s.execute()
for code in response.aggregations.ExitCode.buckets:
print(code.key, code.avgCpuEff.value)