# Help Mapping an Array of ints to Array of Strings to Index on

**URL:** <https://discuss.elastic.co/t/help-mapping-an-array-of-ints-to-array-of-strings-to-index-on/27414>\
**Category:** Elasticsearch\
**Created:** [August 14, 2015, 3:41pm UTC](https://discuss.elastic.co/t/help-mapping-an-array-of-ints-to-array-of-strings-to-index-on/27414 "2015-08-14T15:41:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sklonaris](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sklonaris/32/4198_2.png) [@sklonaris](https://discuss.elastic.co/u/sklonaris)\
**Post date:** [August 14, 2015, 3:41pm UTC](https://discuss.elastic.co/t/help-mapping-an-array-of-ints-to-array-of-strings-to-index-on/27414/1 "2015-08-14T15:41:28Z")

</div>

I am using elastic search in a rails app. I have a model - Posts which and I want to add the tags attribute to my index. The problem is tags are a list of mongoid object id's. So I want to convert them to their string values.

```
class Post
 include Elasticsearch::Model
 include Elasticsearch::Model::Callbacks

 field :title, :type => String
 field :tags, :type => Array, :default => []

  def as_indexed_json(options = {})
    self.as_json({
       only: [:title, :body, :tags => ['string', 'string', 'string']]
    })
  end

end

```

Basically i want to convert [id1, id2, id3] =\> [string1, string2, string3] and index on that

---

<div class="post-metadata">

**Author:** ![karmi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karmi/32/44951_2.png) [@karmi](https://discuss.elastic.co/u/karmi)\
**Post date:** [October 10, 2015, 11:22am UTC](https://discuss.elastic.co/t/help-mapping-an-array-of-ints-to-array-of-strings-to-index-on/27414/2 "2015-10-10T11:22:47Z")

</div>

Hi, you can just call `map` on the tags attribute to convert it to their string values.

---

<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, 11:45pm UTC](https://discuss.elastic.co/t/help-mapping-an-array-of-ints-to-array-of-strings-to-index-on/27414/3 "2017-07-05T23:45:32Z")

</div>


