Select first document in each group

Hi all,

is there a "query" where I can get only the first document of a group of
documents (e.g. all docs have the same value for field "customer")?

in SQL this is something like

id | customer | total
1 | Joe | 5
2 | Sally | 3
3 | Joe | 2
4 | Sally | 1

a query like

SELECT DISTINCT ON (customer)
id, customer, totalFROM purchasesORDER BY customer, total DESC, id

then the result would be

1 | Joe | 5
2 | Sally | 3

So only one document for each "customer" is returned.

Best regards,
Daniel

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

You would probably need to implement a custom facet to support your
request. Identical to a terms facet, but all the values after the first
will be disregarded.

--
Ivan

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Ivan,

thank you for your reply, I suspected something like this.

Best regards,
Daniel

Am Mittwoch, 21. August 2013 23:09:08 UTC+2 schrieb Ivan Brusic:

You would probably need to implement a custom facet to support your
request. Identical to a terms facet, but all the values after the first
will be disregarded.

--
Ivan

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

I was hoping someone else would have a suggestion, but I think that might
be your best bet.

I needed something similar, but I was waiting for the facet framework
refactor to occur before creating another facet type (lots of boilerplate
code is involved). The facet refactor is actually a whole new aggregation
framework which has been detailed but not yet released:
https://github.com/elasticsearch/elasticsearch/issues/3300. Part of what
you are looking for is field collapsing, which is not implement in
elasticsearch. The new aggregation framework does not seem to address it
either.

Cheers,

Ivan

On Wed, Aug 21, 2013 at 9:37 PM, daniel koller danielkoller82@gmail.comwrote:

Hi Ivan,

thank you for your reply, I suspected something like this.

Best regards,
Daniel

Am Mittwoch, 21. August 2013 23:09:08 UTC+2 schrieb Ivan Brusic:

You would probably need to implement a custom facet to support your
request. Identical to a terms facet, but all the values after the first
will be disregarded.

--
Ivan

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.