Aggregate results on specific attribute

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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/1e3a7a13-3f2c-47db-b2f1-b066441d9765%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hello Maarten ,

This is a direct use case of aggregations.
Simpy use term aggregation for both fields -

Thanks
Vineeth

On Sun, Sep 28, 2014 at 1:17 PM, Maarten Roosendaal <mroosendaal14@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+unsubscribe@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+unsubscribe@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.

Hi Vineeth,

Thanks for the reply, it was almost what i was looking for but you pointed
me in the right direction:

Thanks,
Maarten

Op zondag 28 september 2014 17:48:26 UTC+2 schreef vineeth mohan:

Hello Maarten ,

This is a direct use case of aggregations.
Simpy use term aggregation for both fields -
Elasticsearch Platform — Find real-time answers at scale | Elastic

Thanks
Vineeth

On Sun, Sep 28, 2014 at 1:17 PM, Maarten Roosendaal <mroose...@gmail.com
<javascript:>> 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 elasticsearc...@googlegroups.com <javascript:>.
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/066cc62c-21ee-4ffe-946f-14404e39947a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.