I'm having a little trouble in building a query in my current elasticsearch
structure, and I wandered if its possible without changing the modeling.
My current structure is as follows:
I have a parent document type namely 'user', which has many child types
representing the many aspects of a users (the user documents themselves
contain no descriptive information whatsoever).
For example, I may have the child type 'computer' which contains the fields
'screencolor', 'screenwidth' and 'screenheight'. then I may have the child
type 'personal_info' which contains the fields 'name', 'age' and 'address'.
(By definition no different child types will have a field with the same
name, if that matters).
Another thing which is part of my design is the possibility of a single
user containing more than one child of the same type (e.g. one user can
have N computers).
The query I want to execute is as follows:
For every user which match a certain criteria, group the values of the
fields and return me the count of users grouped by the values of the fields.
An example would be:
Grouped by the values of 'screenwidth' and 'age', return me the count of
It would be something like that:
"script_field": "source.age + '' +
This query would return me something like:
The problem is, this only returns me the number of documents which match
the query, which is not the number of users, as there maybe more than 1
child document of the same type per user (by definition).
Is there some way to get what I want in a single query?
It should be clear that I cannot change this architecture, because other
parts of my system which depend on it, but I could create another index
just for this purpose.
Thanks a lot in advance,
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.
For more options, visit https://groups.google.com/groups/opt_out.