# Help with limited result after terms results

**URL:** <https://discuss.elastic.co/t/help-with-limited-result-after-terms-results/103813>\
**Category:** Elasticsearch\
**Created:** [October 13, 2017, 3:08am UTC](https://discuss.elastic.co/t/help-with-limited-result-after-terms-results/103813 "2017-10-13T03:08:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![truongdqse03303](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/truongdqse03303/32/22605_2.png) [@truongdqse03303](https://discuss.elastic.co/u/truongdqse03303)\
**Post date:** [October 13, 2017, 3:08am UTC](https://discuss.elastic.co/t/help-with-limited-result-after-terms-results/103813/1 "2017-10-13T03:08:48Z")

</div>

Hi experts  
Here is my query

```
{
    "size": 0,
    "query": {
        "match_all": {}
    },

    "aggs": {
        "content_level": {
            "terms": {
                "field": "content_level"
            },
            "aggs": {
                "news_id": {
                    "terms": {
                        "field": "news_id"
                    },
                    "aggs": {
                        "viewed_count_max": {
                            "max": {
                                "field": "viewed_count"
                            }
                        },
                        "like_max": {
                            "max": {
                                "field": "liked_count"
                            }
                        }
                    }
                },
                "summmmm": {
                    "sum_bucket": {
                        "buckets_path": "news_id>viewed_count_max"
                    }
                },
                "sum_like": {
                    "sum_bucket": {
                        "buckets_path": "news_id>like_max"
                    }
                }
            }
        },
        "total": {
            "sum_bucket": {
                "buckets_path": "content_level>summmmm"
            }
        }
    }
}

```

With my result i can take the max of viewed\_count and sum it. The problems is the result of terms:field:content\_level is limited so i cant take all the viewed\_count to statistics.  
How can i solve this problems.  
Thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 10, 2017, 3:08am UTC](https://discuss.elastic.co/t/help-with-limited-result-after-terms-results/103813/2 "2017-11-10T03:08:50Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
