I have a data structure containing embedded history, where a docs history is an array of history objects, each of which contains a number of fields.
Unfortunately the avail space for an issue here is limited to 5000 chars - so I had to resort to external links! This is a real shame as these will disappear in time ...
I need to create aggregate queries with conditions on the parent doc as well as on multiple history fields.
This query comes close to the desired result. My data contains the following:
11 docs which contain only a history entry with action_name
21 docs which contain only a history entry with action_name
23 docs which contain both an
implement and a
submit history entry.
Hence a search for just
submited items should (and does) yield 21 + 23 = 44 hits
A search for just
implemented items should (and does) yield 11 + 23 = 34 hits
However, when querying on both aggregating on action_name as per the given query,
the bucket doc_counts contain 55/56 for
submit (should be 44) , 34 for
I do not understand the 55/56 discrepancy, and also noted that 55 is actually
the sum of all docs (11 + 21 + 23).
So it seems the count for
submit results is actually the sum for
Hopefully this is a problem in my query - can anyone point me to it?