I've been working on a BI system with ES 0.90 and we needed count "users"
which have certain attributes, for instance let's say gender and star sign.
A user is a parent-level document and the attributes are child documents.
Fro the sample above, we were doing so by creating a query for each
combination of male / female and the star signs and querying individually,
as one can imagine, this was slow, but the results are exactly what we
want. We could run this in roughly 2 minutes.
We considered using the msearch query to get these results in a single
query and we ended up with something similar to this:
The sample above runs in 40 seconds give or take.
And along came elastic search 1.0.0 and now we have aggregations, so we
simplified our query to this:
This runs lightning fast and we get the results in 200ms on average, which
is ideal for us, BUT we get the total number of documents with the
attributes, rather than the count on the parent documents.
Our problem, as you can see in the msearch gist, is that we have a parent
level document and child documents, which would only be updated if another
document with the exact same attributes came in, this means that a parent
level user document can have three child documents that will have gender
and star sign, but I only want to count the parent document, rather than
each individual child document.
As we don't know in advance the attributes our users will be searching, we
cannot use a script in index time to help us do this aggregation. We tried
to use a script in search time like this:
https://gist.github.com/chaos-generator/9133321 , but it didn't work as we
Any suggestions would be greatly appreciated.
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 firstname.lastname@example.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/3d9a0683-efa3-4398-b546-087005ab2b67%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.