I am trying to use ES to produce a table of several summed fields, grouped
by some other field.
Imagine I have a table of users. Each user has a country field. They also
have a boolean field 'likejazz' and 'likerock' (for ease I store these as 1
or 0 to make the following query faster).
Say I want to produce a table with rows for countries and columns for
number of users, number of users who likejazz and another column for those
who likerock, ordered by the first column decending In SQL I would write
SELECT country, COUNT(*) AS nusers, SUM(likejazz) AS likejazz,
SUM(likerock) AS likerock
GROUP BY country
ORDER BY nusers DESC
Is this possible in ES?
As far as I can see I can only calculate one column at a time (total,
likejazz or likerock) and would have to merge them in code. However, this
is a problem if the grouping is performed across a dimension with lots of
terms as, in order to merge accurately I need results for ALL terms.
As soon as I introduce a limit to any of the column facet calculations, I
may get an error. Imagine I try to retrieve the top 10 in each sub facet
search, the problem is that the ranking for the first column may not match
the following terms returned for the other columns.
Obviously in this case, I could get all the countries and merge, however
for collections with 1000s of terms this in inefficient.
One approach may be to restrict the 2nd and 3rd facet search to just the
terms returned from the first, but not sure thats possible?
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@example.com.
For more options, visit https://groups.google.com/groups/opt_out.