Grouping search results in Elasticsearch


(vibin) #1

Hi All,

Is it possible to group the search results in elastic search by using the
value in particular field (as in DB Query)?

Thanks,
-Vibin

--


(Keith Webster) #2

Hey Vibin,

It's not currently possible as far as I know. Take a look at this thread:
https://groups.google.com/forum/?fromgroups=#!searchin/elasticsearch/group$20results/elasticsearch/ADD0aaKRM-c/lb_LUweod20J

On Thu, Aug 23, 2012 at 1:05 PM, vibin vibindhas@gmail.com wrote:

Hi All,

Is it possible to group the search results in elastic search by using the
value in particular field (as in DB Query)?

Thanks,
-Vibin

--

--


(phill) #3

Why doesn't sorting on several fields work?

If you really want one "row" representing a group, keep in mind that a
group of documents is not a document, document retrieval is about find
matching documents, not making up an ad hoc set of values based on
interesting queries. One way around that is to design a document that
has repeated fields, or children doc, or nested objects and then you can
ask for hits on this larger doc that represents the group.

-Paul
On 8/23/2012 11:05 AM, vibin wrote:

Hi All,

Is it possible to group the search results in elastic search by using
the value in particular field (as in DB Query)?

Thanks,
-Vibin

--


(Jörg Prante) #4

Agreed. It is essential to prepare the documents beforehand when aggregated
data must be represented. Note that parent/children docs, though organized
as relational, is an expensive solution since top_children/has_children
queries have to keep the doc ID loaded in memory or traverse the
structures by query sequences. In short, it is not recommended to throw row
data into in inverted index for aggregation because there is no such thing
like SQL's "group by", "count", "sum" or "avg". You can't model
Elasticsearch inverted indexes as a relational database, and it is strongly
recommended to redesign the data model that should represent aggregated
data.

Best regards,

Jörg

On Thursday, August 30, 2012 5:30:45 PM UTC+2, P Hill wrote:

Why doesn't sorting on several fields work?

If you really want one "row" representing a group, keep in mind that a
group of documents is not a document, document retrieval is about find
matching documents, not making up an ad hoc set of values based on
interesting queries. One way around that is to design a document that
has repeated fields, or children doc, or nested objects and then you can
ask for hits on this larger doc that represents the group.

-Paul
On 8/23/2012 11:05 AM, vibin wrote:

Hi All,

Is it possible to group the search results in elastic search by using
the value in particular field (as in DB Query)?

Thanks,
-Vibin

--


(system) #5