# Does aggregations size property work?

**URL:** <https://discuss.elastic.co/t/does-aggregations-size-property-work/17364>\
**Category:** Elasticsearch\
**Created:** [May 6, 2014, 11:34am UTC](https://discuss.elastic.co/t/does-aggregations-size-property-work/17364 "2014-05-06T11:34:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oswaldo\_Dantas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/oswaldo_dantas/32/1593_2.png) [@Oswaldo\_Dantas](https://discuss.elastic.co/u/Oswaldo_Dantas)\
**Post date:** [May 6, 2014, 11:34am UTC](https://discuss.elastic.co/t/does-aggregations-size-property-work/17364/1 "2014-05-06T11:34:10Z")

</div>

Hello all,

I've tested with versions 1.0.0, 1.1.0 and 1.1.1 and the size property  
doesn't seam to work.

The following works using facets:  
{  
"size": "0",  
"facets": {  
"facettest": {  
"terms": {  
"field": "somefield",  
"size": "5"  
}  
}  
}  
}

The response contains 5 terms as expected, but changing to aggregations:

{  
"size": "0",  
"aggs": {  
"aggtest": {  
"terms": {  
"field": "somefield",  
"size": "5"  
}  
}  
}  
}

Return an 400 error message ending with "Parse Failure [Unknown key for a  
VALUE\_STRING in [aggtest]: [size].]]; }]".

Is there any special requirement or configuration for this to work? The  
documentation talks about this property since some time in  
[http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-terms-aggregation.html#\_size\_amp\_shard\_size](http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-terms-aggregation.html#_size_amp_shard_size)  
but doesn't actually show an usage example.

Cheers,  
Oswaldo

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/126c98a7-9d6e-4709-b6d9-8fe11e0c3b5a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/126c98a7-9d6e-4709-b6d9-8fe11e0c3b5a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Oswaldo\_Dantas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/oswaldo_dantas/32/1593_2.png) [@Oswaldo\_Dantas](https://discuss.elastic.co/u/Oswaldo_Dantas)\
**Post date:** [May 6, 2014, 12:13pm UTC](https://discuss.elastic.co/t/does-aggregations-size-property-work/17364/2 "2014-05-06T12:13:32Z")

</div>

Solved.

Over the irc channel the user @honzakral showed me a working example he had  
and I noticed that for aggregations, the size property cannot be quoted.

On the line of the previous examples, this works:

{  
"size": "1",  
"aggs": {  
"tags": {  
"terms": {  
"field": "usrIdHost",  
"size": 1  
}  
}  
}  
}

Opened a ticket so this inconsistency can be checked:

> <https://github.com/elastic/elasticsearch/issues/6061>
>
> In aggregations, the size property must be unquoted while in other places it can… be quoted (tested in 1.0.0, 1.1.0 and 1.1.1)
> 
> The following work:
> 
> \`\`\` javascript
> {
> "size": "1",
> "aggs": {
> "aggtest": {
> "terms": {
> "field": "somefield",
> "size": 1
> }
> }
> }
> }
> \`\`\`
> 
> But this doesn't:
> 
> \`\`\` javascript
> {
> "size": "1",
> "aggs": {
> "aggtest": {
> "terms": {
> "field": "somefield",
> "size": "1"
> }
> }
> }
> }
> \`\`\`
> 
> Resulting in a 400 error ending in "Parse Failure \[Unknown key for a VALUE\_STRING in \[aggtest\]: \[size\].\]\]; }\]"
> 
> This inconsistency is not mentioned in documentation and the error message is not very helpful, so I could only spot the problem after @HonzaKral pasted a working example on irc.
> 
> I believe at least a fix should be done so all fields behave the same, or with mandatory or with optional quotes, but no two fields with same name but different behaviour.

On Tuesday, May 6, 2014 1:34:10 PM UTC+2, Oswaldo Dantas wrote:

> Hello all,
> 
> I've tested with versions 1.0.0, 1.1.0 and 1.1.1 and the size property  
> doesn't seam to work.
> 
> The following works using facets:  
> {  
> "size": "0",  
> "facets": {  
> "facettest": {  
> "terms": {  
> "field": "somefield",  
> "size": "5"  
> }  
> }  
> }  
> }
> 
> The response contains 5 terms as expected, but changing to aggregations:
> 
> {  
> "size": "0",  
> "aggs": {  
> "aggtest": {  
> "terms": {  
> "field": "somefield",  
> "size": "5"  
> }  
> }  
> }  
> }
> 
> Return an 400 error message ending with "Parse Failure [Unknown key for a  
> VALUE\_STRING in [aggtest]: [size].]]; }]".
> 
> Is there any special requirement or configuration for this to work? The  
> documentation talks about this property since some time in  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-terms-aggregation.html#_size_amp_shard_sizebut) doesn't actually show an usage example.
> 
> Cheers,  
> Oswaldo

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/2b2d5945-eedc-4444-904c-fcf77e756459%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2b2d5945-eedc-4444-904c-fcf77e756459%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Oswaldo\_Dantas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/oswaldo_dantas/32/1593_2.png) [@Oswaldo\_Dantas](https://discuss.elastic.co/u/Oswaldo_Dantas)\
**Post date:** [May 6, 2014, 12:15pm UTC](https://discuss.elastic.co/t/does-aggregations-size-property-work/17364/3 "2014-05-06T12:15:00Z")

</div>

Solved.

Over the irc channel the user @honzakral showed me a working example he had  
and I noticed that for aggregations, the size property cannot be quoted.

On the line of the previous examples, this works:

{  
"size": "5",  
"aggs": {  
"aggtest": {  
"terms": {  
"field": "somefield",  
"size": 5  
}  
}  
}  
}

On Tuesday, May 6, 2014 1:34:10 PM UTC+2, Oswaldo Dantas wrote:

> Hello all,
> 
> I've tested with versions 1.0.0, 1.1.0 and 1.1.1 and the size property  
> doesn't seam to work.
> 
> The following works using facets:  
> {  
> "size": "0",  
> "facets": {  
> "facettest": {  
> "terms": {  
> "field": "somefield",  
> "size": "5"  
> }  
> }  
> }  
> }
> 
> The response contains 5 terms as expected, but changing to aggregations:
> 
> {  
> "size": "0",  
> "aggs": {  
> "aggtest": {  
> "terms": {  
> "field": "somefield",  
> "size": "5"  
> }  
> }  
> }  
> }
> 
> Return an 400 error message ending with "Parse Failure [Unknown key for a  
> VALUE\_STRING in [aggtest]: [size].]]; }]".
> 
> Is there any special requirement or configuration for this to work? The  
> documentation talks about this property since some time in  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-terms-aggregation.html#_size_amp_shard_sizebut) doesn't actually show an usage example.
> 
> Cheers,  
> Oswaldo

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/99de6f9d-139f-496f-aa63-ff5be5aaeb39%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/99de6f9d-139f-496f-aa63-ff5be5aaeb39%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 1:31am UTC](https://discuss.elastic.co/t/does-aggregations-size-property-work/17364/4 "2017-07-06T01:31:23Z")

</div>


