# Get all field names (keys) in an index

**URL:** <https://discuss.elastic.co/t/get-all-field-names-keys-in-an-index/54617>\
**Category:** Elasticsearch\
**Created:** [July 4, 2016, 7:17am UTC](https://discuss.elastic.co/t/get-all-field-names-keys-in-an-index/54617 "2016-07-04T07:17:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ravi\_Shanker\_Reddy](https://avatars.discourse-cdn.com/v4/letter/r/a5b964/32.png) [@Ravi\_Shanker\_Reddy](https://discuss.elastic.co/u/Ravi_Shanker_Reddy)\
**Post date:** [July 4, 2016, 7:17am UTC](https://discuss.elastic.co/t/get-all-field-names-keys-in-an-index/54617/1 "2016-07-04T07:17:17Z")

</div>

In my GUI I want to show all the keys as suggestions. How can I get these keys from elasticsearch using (node js) elasticsearch npm

![](https://us1.discourse-cdn.com/elastic/original/2X/a/aab12d31aa9f24297092ae98c726d1a8124dbab7.png)

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [July 4, 2016, 7:19am UTC](https://discuss.elastic.co/t/get-all-field-names-keys-in-an-index/54617/2 "2016-07-04T07:19:34Z")

</div>

Hey,

you can use the [Get Mapping API](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html) to get all your fields.

--Alex

---

<div class="post-metadata">

**Author:** ![Ravi\_Shanker\_Reddy](https://avatars.discourse-cdn.com/v4/letter/r/a5b964/32.png) [@Ravi\_Shanker\_Reddy](https://discuss.elastic.co/u/Ravi_Shanker_Reddy)\
**Post date:** [July 4, 2016, 7:23am UTC](https://discuss.elastic.co/t/get-all-field-names-keys-in-an-index/54617/3 "2016-07-04T07:23:43Z")

</div>

In this i am getting all scripts and all mappings. Cant I simply this to get only field names???

`curl -XGET '[http://172.16.5.115:9200/ramya\_testing/\_mapping/](http://172.16.5.115:9200/ramya_testing/_mapping/)'?pretty=true  
{  
"ramya\_testing" : {  
"mappings" : {  
"CDRtime" : {  
"properties" : {  
"CDRtime" : {  
"type" : "string",  
"index" : "not\_analyzed"  
}  
}  
},  
"logs" : {  
"properties" : {  
"@timestamp" : {  
"type" : "date",  
"format" : "strict\_date\_optional\_time||epoch\_millis"  
},  
"@version" : {  
"type" : "string"  
},  
"aggs" : {  
"properties" : {  
"Field names" : {  
"properties" : {  
"terms" : {  
"properties" : {  
"field" : {  
"type" : "string"  
},  
"size" : {  
"type" : "long"  
}  
}  
}  
}  
}  
}  
},  
"column1" : {  
"type" : "string"  
},  
"column10" : {  
"type" : "string"  
},  
"column11" : {  
"type" : "string"  
},  
"column12" : {  
"type" : "string"  
},  
"column13" : {  
"type" : "string"  
},  
"column14" : {  
"type" : "string"  
},  
"column15" : {  
"type" : "string"  
},  
"column16" : {  
"type" : "string"  
},  
"column17" : {  
"type" : "string"  
},  
"column18" : {  
"type" : "string"  
},  
"column2" : {  
"type" : "string"  
},  
"column20" : {  
"type" : "string"  
},  
"column21" : {  
"type" : "string"  
},  
"column23" : {  
"type" : "string"  
},  
"column24" : {  
"type" : "string"  
},  
"column25" : {  
"type" : "string"  
},  
"column26" : {  
"type" : "string"  
},  
"column27" : {  
"type" : "string"  
},  
"column28" : {  
"type" : "string"  
},  
"column29" : {  
"type" : "string"  
},  
"column3" : {  
"type" : "string"  
},  
"column30" : {  
"type" : "string"  
},  
"column31" : {  
"type" : "string"  
},  
"column32" : {  
"type" : "string"  
},  
"column33" : {  
"type" : "string"  
},  
"column34" : {  
"type" : "string"  
},  
"column35" : {  
"type" : "string"  
},  
"column36" : {  
"type" : "string"  
},  
"column38" : {  
"type" : "string"  
},  
"column39" : {  
"type" : "string"  
},  
"column4" : {  
"type" : "string"  
},  
"column40" : {  
"type" : "string"  
},  
"column41" : {  
"type" : "string"  
},  
"column42" : {  
"type" : "string"  
},  
"column43" : {  
"type" : "string"  
},  
"column44" : {  
"type" : "string"  
},  
"column45" : {  
"type" : "string"  
},  
"column46" : {  
"type" : "string"  
},  
"column47" : {  
"type" : "string"  
},  
"column48" : {  
"type" : "string"  
},  
"column49" : {  
"type" : "string"  
},  
"column5" : {  
"type" : "string"  
},  
"column50" : {  
"type" : "string"  
},  
"column51" : {  
"type" : "string"  
},  
"column52" : {  
"type" : "string"  
},  
"column53" : {  
"type" : "string"  
},  
"column54" : {  
"type" : "string"  
},  
"column55" : {  
"type" : "string"  
},  
"column56" : {  
"type" : "string"  
},  
"column57" : {  
"type" : "string"  
},  
"column58" : {  
"type" : "string"  
},  
"column59" : {  
"type" : "string"  
},  
"column6" : {  
"type" : "string"  
},

.......................... and so on

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [July 4, 2016, 7:25am UTC](https://discuss.elastic.co/t/get-all-field-names-keys-in-an-index/54617/4 "2016-07-04T07:25:46Z")

</div>

That is the Get mapping API, so you are using the correct endpoint already. I dont understand your question then? Where is your problem of using that API?

---

<div class="post-metadata">

**Author:** ![Ravi\_Shanker\_Reddy](https://avatars.discourse-cdn.com/v4/letter/r/a5b964/32.png) [@Ravi\_Shanker\_Reddy](https://discuss.elastic.co/u/Ravi_Shanker_Reddy)\
**Post date:** [July 4, 2016, 8:02am UTC](https://discuss.elastic.co/t/get-all-field-names-keys-in-an-index/54617/5 "2016-07-04T08:02:01Z")

</div>

Very thanks. That get mapping solves it

---

<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 5, 2017, 10:38pm UTC](https://discuss.elastic.co/t/get-all-field-names-keys-in-an-index/54617/6 "2017-07-05T22:38:35Z")

</div>


