Aggregation on fields within nested objects in elasticsearch

I was not speaking about the implementation details but about the need.

If you are trying to compute on "item", then index "item" and not a group of items.

Is there a way to fetch only the corresponding quantity of a given item in an array of items for a given object?

I don't know but may be provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem.