# Mapping for an array of keywords

**URL:** <https://discuss.elastic.co/t/mapping-for-an-array-of-keywords/172200>\
**Category:** Elasticsearch\
**Created:** [March 13, 2019, 6:35pm UTC](https://discuss.elastic.co/t/mapping-for-an-array-of-keywords/172200 "2019-03-13T18:35:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vincent\_Stevenson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vincent_stevenson/32/48477_2.png) [@Vincent\_Stevenson](https://discuss.elastic.co/u/Vincent_Stevenson)\
**Post date:** [March 13, 2019, 6:35pm UTC](https://discuss.elastic.co/t/mapping-for-an-array-of-keywords/172200/1 "2019-03-13T18:35:37Z")

</div>

What does the JSON mapping look like if I have a field that is of type: keyword array.

If I wanted multiple keywords associated with a JSON document, how would I create the mapping for the index's field?

Something like:  
"my\_index" : {  
"mappings" : {  
"item": {  
"properties" : {  
"NickNames" : { "type" : "keyword array"}  
}  
}  
}  
}

Thanks!

---

<div class="post-metadata">

**Author:** ![bram](https://avatars.discourse-cdn.com/v4/letter/b/9d8465/32.png) [@bram](https://discuss.elastic.co/u/bram)\
**Post date:** [March 13, 2019, 8:27pm UTC](https://discuss.elastic.co/t/mapping-for-an-array-of-keywords/172200/2 "2019-03-13T20:27:03Z")

</div>

You can just use keyword.  
In Elasticsearch every field is already an array, see the docs here:

> **[Field data types | Elasticsearch Guide \[8.11\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html)**

> Array support does not require a dedicated `type`

And you can set a single value or multiple values when indexing the documents:  
{"nickNames": "foo"}  
{"nickNames: ["foo"]}  
{"nickNames: ["foo", "bar"]}

---

<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:** [April 10, 2019, 8:27pm UTC](https://discuss.elastic.co/t/mapping-for-an-array-of-keywords/172200/3 "2019-04-10T20:27:04Z")

</div>

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