# How to Index an Array as Field names

**URL:** <https://discuss.elastic.co/t/how-to-index-an-array-as-field-names/185000>\
**Category:** Elasticsearch\
**Created:** [June 10, 2019, 1:36pm UTC](https://discuss.elastic.co/t/how-to-index-an-array-as-field-names/185000 "2019-06-10T13:36:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![matheusribeirogarcia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matheusribeirogarcia/32/44363_2.png) [@matheusribeirogarcia](https://discuss.elastic.co/u/matheusribeirogarcia)\
**Post date:** [June 10, 2019, 1:36pm UTC](https://discuss.elastic.co/t/how-to-index-an-array-as-field-names/185000/1 "2019-06-10T13:36:47Z")

</div>

Is there a way to Index an Object in this format, for example,

> [Name, Phone, Address]

It can be multiple positions aswell, not exactly these three

And put in a Index using the javascript API like this:

```
this.es.addToIndex({
          index: 'name_of_index',
          type: 'type_of_index', 
          body: {
            name: form.value.name,
            title: form.value.title,
             description: form.value.description,
             published: new Date().toLocaleString(),
             script: this.alternativeFields.value,
             "Name":"",
              "Phone":"",
             "Address":""
          }

```

Basically this Array can be anything, I've tried several things, like using javascript eval, but none of these tries worked, also, didn't find any elastic function that allows me to do that, please help.

---

<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 8, 2019, 1:50pm UTC](https://discuss.elastic.co/t/how-to-index-an-array-as-field-names/185000/2 "2019-07-08T13:50:37Z")

</div>

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