# How to get average of items in an array of a nested field?

**URL:** <https://discuss.elastic.co/t/how-to-get-average-of-items-in-an-array-of-a-nested-field/322690>\
**Category:** Elasticsearch\
**Created:** [January 8, 2023, 9:34pm UTC](https://discuss.elastic.co/t/how-to-get-average-of-items-in-an-array-of-a-nested-field/322690 "2023-01-08T21:34:51Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![learningelastic](https://avatars.discourse-cdn.com/v4/letter/l/958977/32.png) [@learningelastic](https://discuss.elastic.co/u/learningelastic)\
**Post date:** [January 9, 2023, 12:32am UTC](https://discuss.elastic.co/t/how-to-get-average-of-items-in-an-array-of-a-nested-field/322690/6 "2023-01-09T00:32:28Z")

</div>

And a related problem...by adding `properties.inventory.type: "nested"` to the mapping, kibana lens can no longer access any of the `inventory.*` fields. I posted the problem as a separate question here:

> [@Kibana Visualize Lens not showing nested fields](https://discuss.elastic.co/t/kibana-visualize-lens-not-showing-nested-fields/322691):
>
> I'm not sure what I did wrong, but Kibana Lenses aren't showing me the nested field inventory.equipment. In terms of what I did, I set up an index and added a document with this script: PUT warehouse POST warehouse/\_mapping { "properties": { "inventory": { "type": "nested", "properties": { "equipment": { "type": "keyword" }, "price": { "type": "float" } } }, "profile": { "properties": { "name": { …

---

_[View the full topic](https://discuss.elastic.co/t/how-to-get-average-of-items-in-an-array-of-a-nested-field/322690)._
