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. 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 | ======================================================================================== 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. 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/FA25DC0F-39A9-4131-B6FF-F0EEC4E6C99C%40pilato.fr. For more options, visit https://groups.google.com/d/optout.
