# How to do "offset" on aggreation results

**URL:** <https://discuss.elastic.co/t/how-to-do-offset-on-aggreation-results/76314>\
**Category:** Elasticsearch\
**Created:** [February 23, 2017, 9:38pm UTC](https://discuss.elastic.co/t/how-to-do-offset-on-aggreation-results/76314 "2017-02-23T21:38:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lukasz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukasz/32/15817_2.png) [@Lukasz](https://discuss.elastic.co/u/Lukasz)\
**Post date:** [February 23, 2017, 9:38pm UTC](https://discuss.elastic.co/t/how-to-do-offset-on-aggreation-results/76314/1 "2017-02-23T21:38:25Z")

</div>

Hi,  
I have problem with writing query in Elastic. I have 1 milion parts and daily statistic for them. What i want to do is display all parts in 1000 chunks. Generally table with download count 😉  
So query in sql would look like  
'select count(id) from stats group by part limt 1000'  
'select count(id) from stats group by part limt 1000 offset 1000'  
And so on.  
So in elastic i have to use aggregation but when i do i can`t use 'from' on it.

Does anybody has some advice on this ?

---

<div class="post-metadata">

**Author:** ![jkuang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jkuang/32/72637_2.png) [@jkuang](https://discuss.elastic.co/u/jkuang)\
**Post date:** [February 24, 2017, 1:16am UTC](https://discuss.elastic.co/t/how-to-do-offset-on-aggreation-results/76314/2 "2017-02-24T01:16:09Z")

</div>

In ES there is no such thing as a count with a limit. The limit in ES is more of a pagination upper bound - from & size and is not include in the count aggregation.

Any how, I believe "limit" is not of significance in what you're trying to do. In your sql statement, if the results are more than 1000, the count will return 1000. If the count is less than 1000, it will return X, where X \<=1000

```auto
GET products/_search
{
    "aggs" : {
        "myname_count" : { 
          "value_count" : { 
            "field" : "price" 
            
          } 
          
        }
    }
}

```

The above will return the count value of group price. If value\_count returns more than 1000, then you just mentally note that is should be 1000. If it is less than 1000, you will know what that X value is.

---

<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:** [March 24, 2017, 1:16am UTC](https://discuss.elastic.co/t/how-to-do-offset-on-aggreation-results/76314/3 "2017-03-24T01:16:13Z")

</div>

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