# Elasticsearch php nested aggregations

**URL:** <https://discuss.elastic.co/t/elasticsearch-php-nested-aggregations/133012>\
**Category:** Elasticsearch\
**Created:** [May 23, 2018, 2:55pm UTC](https://discuss.elastic.co/t/elasticsearch-php-nested-aggregations/133012 "2018-05-23T14:55:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sewox](https://avatars.discourse-cdn.com/v4/letter/s/838e76/32.png) [@sewox](https://discuss.elastic.co/u/sewox)\
**Post date:** [May 23, 2018, 2:55pm UTC](https://discuss.elastic.co/t/elasticsearch-php-nested-aggregations/133012/1 "2018-05-23T14:55:58Z")

</div>

hi everyone,  
i tired searching an trying.  
I need to group the nested fields.  
The sql query is as follows  
SELECT p\_application\_category,Sum(p\_recv\_bytes) as download,p\_date FROM ZLog2 $w group by p\_application\_category;

---

<div class="post-metadata">

**Author:** ![thiago](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago/32/32096_2.png) [@thiago](https://discuss.elastic.co/u/thiago)\
**Post date:** [May 25, 2018, 3:39am UTC](https://discuss.elastic.co/t/elasticsearch-php-nested-aggregations/133012/2 "2018-05-25T03:39:30Z")

</div>

We need a little bit more of context so we can help you. Are you trying to translate that SQL query into an ES query? If so, how is the mapping for ZLog2 index (assuming this the name of index)? And what nested fields are you referring to?

---

<div class="post-metadata">

**Author:** ![sewox](https://avatars.discourse-cdn.com/v4/letter/s/838e76/32.png) [@sewox](https://discuss.elastic.co/u/sewox)\
**Post date:** [May 30, 2018, 7:21am UTC](https://discuss.elastic.co/t/elasticsearch-php-nested-aggregations/133012/3 "2018-05-30T07:21:43Z")

</div>

I went through the problem with ElasticSearch sql plugin  
Thank you.

---

<div class="post-metadata">

**Author:** ![thiago](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago/32/32096_2.png) [@thiago](https://discuss.elastic.co/u/thiago)\
**Post date:** [May 30, 2018, 11:53am UTC](https://discuss.elastic.co/t/elasticsearch-php-nested-aggregations/133012/4 "2018-05-30T11:53:36Z")

</div>

You mean the new Elasticsearch SQL Plugin being developed that is currently unreleased? Can you give more details of the issue? What you mean by `group the nested fields? Which nestes fields?

Or did you mean some third-party SQL plugin?

---

<div class="post-metadata">

**Author:** ![sewox](https://avatars.discourse-cdn.com/v4/letter/s/838e76/32.png) [@sewox](https://discuss.elastic.co/u/sewox)\
**Post date:** [May 31, 2018, 7:37am UTC](https://discuss.elastic.co/t/elasticsearch-php-nested-aggregations/133012/5 "2018-05-31T07:37:51Z")

</div>

i using new Elasticsearch SQL Plugin .  
example Code:  
"curl -H "Content-Type: application/json" -XGET '[http://localhost:9200/\_sql?pretty](http://localhost:9200/_sql?pretty)' -d 'SELECT SUM(nested(byte.Recived)) download FROM useroam\_2018.05.28 Group BY nested(source.Ip) LIMIT 10'  
"  
this code collects and groups the nested fields and returns them as a grouped result download

---

<div class="post-metadata">

**Author:** ![thiago](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago/32/32096_2.png) [@thiago](https://discuss.elastic.co/u/thiago)\
**Post date:** [May 31, 2018, 12:30pm UTC](https://discuss.elastic.co/t/elasticsearch-php-nested-aggregations/133012/6 "2018-05-31T12:30:49Z")

</div>

The new official SQL plugin endpoint is `POST /_xpack/sql` and not `GET /_sql` (see [https://www.elastic.co/guide/en/elasticsearch/reference/6.x/sql-rest.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.x/sql-rest.html)).

I am not sure what plugin is this that answers with `GET /_sql`. Maybe is this one [https://github.com/NLPchina/elasticsearch-sql](https://github.com/NLPchina/elasticsearch-sql) ? If so, this is a third-party plugin in which I am not aware of how it works.

---

<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:** [June 28, 2018, 12:39pm UTC](https://discuss.elastic.co/t/elasticsearch-php-nested-aggregations/133012/7 "2018-06-28T12:39:59Z")

</div>

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