# Collect the nested fields

**URL:** <https://discuss.elastic.co/t/collect-the-nested-fields/238528>\
**Category:** Elasticsearch\
**Created:** [June 24, 2020, 3:54pm UTC](https://discuss.elastic.co/t/collect-the-nested-fields/238528 "2020-06-24T15:54:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aviman](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@aviman](https://discuss.elastic.co/u/aviman)\
**Post date:** [June 24, 2020, 3:54pm UTC](https://discuss.elastic.co/t/collect-the-nested-fields/238528/1 "2020-06-24T15:54:38Z")

</div>

Hi,

How can I collect the nested fields names only:

```auto
"variable" : {
	"XX" : {
		"value" : "1"
	},
	"YY" : {
		"value" : "2"
	}

```

How can i extract the nested filed names "XX" & "YY" using painless script

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 22, 2020, 3:55pm UTC](https://discuss.elastic.co/t/collect-the-nested-fields/238528/2 "2020-07-22T15:55:00Z")

</div>

Closed on July 22, 2020, 3:55pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
