Hello Maarten , This is a direct use case of aggregations. Simpy use term aggregation for both fields - http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations.html
Thanks Vineeth On Sun, Sep 28, 2014 at 1:17 PM, Maarten Roosendaal <mroosendaa...@gmail.com > wrote: > Hi, > > I'm trying to solve the following use case with elasticsearch: we want to > provide users with autocomplete functionality but the results of a typed > term should be aggregated by type of entity in the index, like brand and > creator. > > For example, i have this in the index (name, type, score) > brand a score 10 > brand aa score 20 > brand aaa score 11 > brand aaaa score 9 > > creator a score 30 > creator aa score 10 > creator aaa score 9 > creator aaaa score 11 > > what i want: top 2 highest scoring results per type (brand, creator) for > search 'starts with a' should be: > brand > brand aa > brand aaa > creator > creator a > creator aaaa > > how can you do this in es? Or do i have to use multiple queries (per type) > and aggregate the result in the application? > > Thanks, > Maarten > > -- > 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+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elasticsearch/1e3a7a13-3f2c-47db-b2f1-b066441d9765%40googlegroups.com > <https://groups.google.com/d/msgid/elasticsearch/1e3a7a13-3f2c-47db-b2f1-b066441d9765%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 the Google Groups "elasticsearch" group. To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAGdPd5%3DyBT1o-vSNScX3Vy0SujbVcG_b1gjf4eZecW8_RNdjgA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.