Elasticsearch聚合随着时间的推移而减慢

时间:2014-05-02 10:03:24

标签: elasticsearch

当尝试在循环中使用多个聚合进行查询时,查询时间变得非常慢。 结果应该给我每种类型的计数。

我发送的JSON看起来像这样

GET events / _search { "size": 0, "aggs": { "count_by_types_38": { "filter": { "term": { "data.campaign_id": 38 } }, "aggs": { "field": { "terms": { "field": "_type", "min_doc_count": 0 } } } }, "count_by_types_39": { "filter": { "term": { "data.campaign_id": 39 } }, "aggs": { "field": { "terms": { "field": "_type", "min_doc_count": 0 } } } }, "count_by_types_40": { "filter": { "term": { "data.campaign_id": 40 } }, "aggs": { "field": { "terms": { "field": "_type", "min_doc_count": 0 } } } }, "count_by_types_41": { "filter": { "term": { "data.campaign_id": 41 } }, "aggs": { "field": { "terms": { "field": "_type", "min_doc_count": 0 } } } }, "count_by_types_42": { "filter": { "term": { "data.campaign_id": 42 } }, "aggs": { "field": { "terms": { "field": "_type", "min_doc_count": 0 } } } }, "count_by_types_44": { "filter": { "term": { "data.campaign_id": 44 } }, "aggs": { "field": { "terms": { "field": "_type", "min_doc_count": 0 } } } }, "count_by_types_45": { "filter": { "term": { "data.campaign_id": 45 } }, "aggs": { "field": { "terms": { "field": "_type", "min_doc_count": 0 } } } }, "count_by_types_46": { "filter": { "term": { "data.campaign_id": 46 } }, "aggs": { "field": { "terms": { "field": "_type", "min_doc_count": 0 } } } }, "count_by_types_47": { "filter": { "term": { "data.campaign_id": 47 } }, "aggs": { "field": { "terms": { "field": "_type", "min_doc_count": 0 } } } }, "count_by_types_48": { "filter": { "term": { "data.campaign_id": 48 } }, "aggs": { "field": { "terms": { "field": "_type", "min_doc_count": 0 } } } } }, "query": { "match_all": {} } }

对于循环中的每次迭代,我都会更改data.campaign_id。

我尝试使用较少数量的聚合,但它并没有真正改变任何内容。

在ES返回结果之前需要大约40秒才能进行8-12次迭代,并且我将其杀死。

如果我只使用一个聚合运行查询,则没有问题。

我做错了吗?

1 个答案:

答案 0 :(得分:0)

问题是我的开发服务器很小。