Check terms aggregation, it allow return specified top field in a group, can i return the whole doc there?
On Thu, Mar 20, 2014 at 4:36 PM, David Pilato <[email protected]> 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 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/etPan.532ab696.3fa62aca.97ca%40MacBook-Air-de-David.local<https://groups.google.com/d/msgid/elasticsearch/etPan.532ab696.3fa62aca.97ca%40MacBook-Air-de-David.local?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/CANihJfXAHRwDP9T1%2BTsUR24CGqv3MQVBnFgTD9Q6imApG_R37Q%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
