Might be the weird use-case I'm having here.
If you read the other post I made [Theoretical] How does query filtering upon nested aggregation work?, basically the third question might be the issue here..
-
Does this part of the query:
"terms": { "nested_aggregation": [4, 8] }
filter out the values from the documents themselves or aggregations buckets?
Ps: If this still doesn't make sense, I'll try creating a reproduction of the problem so you can try running it.