Indeed sounds like https://github.com/elasticsearch/elasticsearch/issues/256
Not easy to do. On Tuesday, March 25, 2014 2:20:42 AM UTC, Otis Gospodnetic wrote: > > Hi David, > > I looked around and haven't been able to find any examples of bucket > aggregations other than terms one. I think the way this aggregation is > described makes it sound like group by in RDBMS world, but it looks like > that's not the case. > > Take this pseudo-example: > > SELECT category, city, makemodel > FROM cars > GROUP BY category TOP 2 > > In a DB world this could return the following: > > > ======================================================================================== > | category | city | makemodel > | > > ======================================================================================== > | compact | u.s.a./texas/houston | asian/acura/tl > | > | compact | u.s.a./florida/tampa | asian/acura/1.6el > | > > +---------------+---------------------------------+------------------------------------+ > | exotic | u.s.a./florida/tampa | european/bentley/azure > | > | exotic | u.s.a./california/san francisco | european/bentley/azure > | > > ======================================================================================== > > Note how each row is a full row/document. I think this is the key part. > > Can ES aggregations do this? > If so, could you please share an example or point me to it? None of the > examples of bucket aggregates I saw showed this. > > As far as I can tell, the above cannot be done with ES aggregations > because it's essentially like "field collapsing" functionality that's not > in ES yet, but maybe I'm missing something... > > Thanks, > Otis > -- > Performance Monitoring * Log Analytics * Search Analytics > Solr & Elasticsearch Support * http://sematext.com/ > > > > On Thursday, March 20, 2014 5:36:22 AM UTC-4, David Pilato wrote: >> >> Terms aggregation should be what you are looking for. >> >> -- >> *David Pilato* | *Technical Advocate* | *Elasticsearch.com* >> @dadoonet <https://twitter.com/dadoonet> | >> @elasticsearchfr<https://twitter.com/elasticsearchfr> >> >> >> Le 20 mars 2014 à 10:24:02, Nguyen Manh Tien ([email protected]) a >> écrit: >> >> Thanks David, >> >> If you check my sample above, i don't want any aggregate info (min, max, >> count, ...) for each group, just want to get top N result from each group, >> is this possible? >> >> >> On Thu, Mar 20, 2014 at 1:53 PM, David Pilato <[email protected]> wrote: >> >>> Have a look at aggregations. >>> >>> -- >>> David ;-) >>> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs >>> >>> >>> Le 20 mars 2014 à 03:55, Nguyen Manh Tien <[email protected]> a >>> écrit : >>> >>> Hello, >>> >>> In SQL i can use GROUP BY to limit number of rows in each group like >>> bellow. >>> Is there any way to do that in ElasticSearch? >>> >>> Thanks. >>> >>> 1. >>> >>> *Find the first 10 groups of cars, with 2 hits in each group:* >>> >>> SELECT category, city, makemodel >>> FROM cars >>> GROUP BY category TOP 2 >>> >>> *Results:* >>> >>> >>> ======================================================================================== >>> | category | city | makemodel >>> | >>> >>> ======================================================================================== >>> | compact | u.s.a./texas/houston | asian/acura/tl >>> | >>> | compact | u.s.a./florida/tampa | asian/acura/1.6el >>> | >>> >>> +---------------+---------------------------------+------------------------------------+ >>> | exotic | u.s.a./florida/tampa | >>> european/bentley/azure | >>> | exotic | u.s.a./california/san francisco | >>> european/bentley/azure | >>> >>> ======================================================================================== >>> >>> 2. >>> >>> *Find the numbers of cars in different categories:* >>> >>> SELECT category, grouphitscount >>> FROM cars >>> GROUP BY category top 1 >>> >>> *Results:* >>> >>> +---------------+----------------+ >>> | category | grouphitscount | >>> +---------------+----------------+ >>> | compact | 4169 | >>> | exotic | 1902 | >>> >>> >>> -- >>> 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 [email protected]. >>> >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/elasticsearch/c1e2d776-e006-430c-82a0-389e3fc6731c%40googlegroups.com<https://groups.google.com/d/msgid/elasticsearch/c1e2d776-e006-430c-82a0-389e3fc6731c%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> -- >>> You received this message because you are subscribed to a topic in the >>> Google Groups "elasticsearch" group. >>> To unsubscribe from this topic, visit >>> https://groups.google.com/d/topic/elasticsearch/8GZHBLh1vsc/unsubscribe. >>> To unsubscribe from this group and all its topics, send an email to >>> [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/elasticsearch/FA25DC0F-39A9-4131-B6FF-F0EEC4E6C99C%40pilato.fr<https://groups.google.com/d/msgid/elasticsearch/FA25DC0F-39A9-4131-B6FF-F0EEC4E6C99C%40pilato.fr?utm_medium=email&utm_source=footer>. >>> >>> >>> >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- >> 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 [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/elasticsearch/CANihJfWFQZb_rbUHdEG8X_jQDA%2BgJHhsz_m0Erjd4h-sZJmp7Q%40mail.gmail.com<https://groups.google.com/d/msgid/elasticsearch/CANihJfWFQZb_rbUHdEG8X_jQDA%2BgJHhsz_m0Erjd4h-sZJmp7Q%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> >> -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/5542fac6-59b1-4033-805c-170e6d500ec9%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
