# Aggregate Query in ElasticSearch / Lucene

**URL:** <https://discuss.elastic.co/t/aggregate-query-in-elasticsearch-lucene/6519>\
**Category:** Elasticsearch\
**Created:** [January 27, 2012, 5:54am UTC](https://discuss.elastic.co/t/aggregate-query-in-elasticsearch-lucene/6519 "2012-01-27T05:54:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raul\_Jr\_Martinez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raul_jr_martinez/32/1286_2.png) [@Raul\_Jr\_Martinez](https://discuss.elastic.co/u/Raul_Jr_Martinez)\
**Post date:** [January 27, 2012, 5:54am UTC](https://discuss.elastic.co/t/aggregate-query-in-elasticsearch-lucene/6519/1 "2012-01-27T05:54:10Z")

</div>

Hi,

I work in a company that uses Endeca for search and we are heavily relying  
on aggregate queries (GROUP BY). Right now, is there an equivalent feature  
in ES or Lucene?

Thanks  
Raul

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 27, 2012, 6:13am UTC](https://discuss.elastic.co/t/aggregate-query-in-elasticsearch-lucene/6519/2 "2012-01-27T06:13:56Z")

</div>

Have a look at the facet concept

HTH  
David 😉  
@dadoonet

Le 27 janv. 2012 à 06:54, "Raul, Jr. Martinez" [juneym@gmail.com](mailto:juneym@gmail.com) a écrit :

> Hi,
> 
> I work in a company that uses Endeca for search and we are heavily relying on aggregate queries (GROUP BY). Right now, is there an equivalent feature in ES or Lucene?
> 
> Thanks  
> Raul

---

<div class="post-metadata">

**Author:** ![Karussell1](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@Karussell1](https://discuss.elastic.co/u/Karussell1)\
**Post date:** [January 30, 2012, 9:26am UTC](https://discuss.elastic.co/t/aggregate-query-in-elasticsearch-lucene/6519/3 "2012-01-30T09:26:26Z")

</div>

what is the 'group by' exactly doing? in lucene there is a grouping  
feature, in elasticsearch there is parent/child ...

Peter.

On Jan 27, 6:54 am, "Raul, Jr. Martinez" [jun...@gmail.com](mailto:jun...@gmail.com) wrote:

> Hi,
> 
> I work in a company that uses Endeca for search and we are heavily relying  
> on aggregate queries (GROUP BY). Right now, is there an equivalent feature  
> in ES or Lucene?
> 
> Thanks  
> Raul

---

<div class="post-metadata">

**Author:** ![Shairon\_Toledo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shairon_toledo/32/2490_2.png) [@Shairon\_Toledo](https://discuss.elastic.co/u/Shairon_Toledo)\
**Post date:** [January 30, 2012, 2:57pm UTC](https://discuss.elastic.co/t/aggregate-query-in-elasticsearch-lucene/6519/4 "2012-01-30T14:57:03Z")

</div>

Hi,

ES and Lucene have a feature called "facets", it groups results according  
to a field value, the count is also returned in the result, similar to a  
aggregation "group by" SQL/DML function. For more details

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

On Mon, Jan 30, 2012 at 7:26 AM, Karussell [tableyourtime@googlemail.com](mailto:tableyourtime@googlemail.com)wrote:

> what is the 'group by' exactly doing? in lucene there is a grouping  
> feature, in elasticsearch there is parent/child ...
> 
> Peter.
> 
> On Jan 27, 6:54 am, "Raul, Jr. Martinez" [jun...@gmail.com](mailto:jun...@gmail.com) wrote:
> 
> > Hi,
> > 
> > I work in a company that uses Endeca for search and we are heavily  
> > relying  
> > on aggregate queries (GROUP BY). Right now, is there an equivalent  
> > feature  
> > in ES or Lucene?
> > 
> > Thanks  
> > Raul

--  
's  
Shairon Toledo  
[http://www.google.com/profiles/shairon.toledo](http://www.google.com/profiles/shairon.toledo)

---

<div class="post-metadata">

**Author:** ![Raul\_Jr\_Martinez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raul_jr_martinez/32/1286_2.png) [@Raul\_Jr\_Martinez](https://discuss.elastic.co/u/Raul_Jr_Martinez)\
**Post date:** [May 8, 2012, 6:34am UTC](https://discuss.elastic.co/t/aggregate-query-in-elasticsearch-lucene/6519/5 "2012-05-08T06:34:22Z")

</div>

Sorry for the late response.

The "Group By" feature collapses several records into a single record (a  
representative record with complete fields).  
I will investigate more on parent/child feature of Elasticsearch.

Thank you Peter.

@David, @Shairon:  
Facets is an alternative solution but I would like to still get all the  
fields of the representative record.

Thanks  
Raul

On Monday, January 30, 2012 5:26:26 PM UTC+8, Karussell wrote:

> what is the 'group by' exactly doing? in lucene there is a grouping  
> feature, in elasticsearch there is parent/child ...
> 
> Peter.
> 
> On Jan 27, 6:54 am, "Raul, Jr. Martinez" [jun...@gmail.com](mailto:jun...@gmail.com) wrote:
> 
> > Hi,
> > 
> > I work in a company that uses Endeca for search and we are heavily  
> > relying  
> > on aggregate queries (GROUP BY). Right now, is there an equivalent  
> > feature  
> > in ES or Lucene?
> > 
> > Thanks  
> > Raul

---

<div class="post-metadata">

**Author:** ![Dennis](https://avatars.discourse-cdn.com/v4/letter/d/e56c9b/32.png) [@Dennis](https://discuss.elastic.co/u/Dennis)\
**Post date:** [July 7, 2013, 9:02pm UTC](https://discuss.elastic.co/t/aggregate-query-in-elasticsearch-lucene/6519/6 "2013-07-07T21:02:32Z")

</div>

were you able t ok get the representative record and aggregation from Elasticsearch?

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:27am UTC](https://discuss.elastic.co/t/aggregate-query-in-elasticsearch-lucene/6519/7 "2017-07-06T02:27:48Z")

</div>


