# Need help to create array type field in elastic search

**URL:** <https://discuss.elastic.co/t/need-help-to-create-array-type-field-in-elastic-search/20236>\
**Category:** Elasticsearch\
**Created:** [October 14, 2014, 10:07am UTC](https://discuss.elastic.co/t/need-help-to-create-array-type-field-in-elastic-search/20236 "2014-10-14T10:07:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phani\_Nadiminti](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/phani_nadiminti/32/45381_2.png) [@Phani\_Nadiminti](https://discuss.elastic.co/u/Phani_Nadiminti)\
**Post date:** [October 14, 2014, 10:07am UTC](https://discuss.elastic.co/t/need-help-to-create-array-type-field-in-elastic-search/20236/1 "2014-10-14T10:07:29Z")

</div>

Hi All,

I have a scenario like In elastic search i want to create custom  
mapping.The data will be insert into index using java API . Now i have a  
field with multi values like "1,2,3" .Field name is categories. can you  
please tell me how to create a custom mapping for type array so that when i  
insert data in to elastic search index the categories type is need to be an  
string array which can hold multi values.(string array).

catgories : [  
"1",  
"2",  
"3"  
]

```
    I used river bracket notation to dynamically create array at 

```

elastic search using bracket notation.but from java API how can we create  
custom mapping so that it can hold multi values.

Thanks

phani

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/22bd6f5c-2d90-4fa6-9f1d-2009ff7fda99%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/22bd6f5c-2d90-4fa6-9f1d-2009ff7fda99%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![brian\_yoder](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@brian\_yoder](https://discuss.elastic.co/u/brian_yoder)\
**Post date:** [October 14, 2014, 6:35pm UTC](https://discuss.elastic.co/t/need-help-to-create-array-type-field-in-elastic-search/20236/2 "2014-10-14T18:35:44Z")

</div>

There is nothing special you need to add to your mapping to enable multiple  
values for a field. Just pass in an array of values instead of a single  
value, and all of the values are analyzed.

One thing you might want to add for string fields with multiple values:

"position\_offset\_gap" : _n_

When a string field is analyzed, it typically assigns a position to each  
token that is one greater than the position of the previous token. By  
setting a position offset gap value to _n_, it skips ahead that many  
positions, representing the number of non-matching word positions between  
consecutive values.

What this does is that if your field contains multiple values that each has  
multiple words, a phrase query won't span across values unless the slop  
value is large enough (n or larger, I seem to recall).

Hope this helps.

Brian

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e2d2dd14-d899-4e1e-a909-ce9e305f900a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e2d2dd14-d899-4e1e-a909-ce9e305f900a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![AngeloDamato](https://avatars.discourse-cdn.com/v4/letter/a/e79b87/32.png) [@AngeloDamato](https://discuss.elastic.co/u/AngeloDamato)\
**Post date:** [October 15, 2014, 7:12am UTC](https://discuss.elastic.co/t/need-help-to-create-array-type-field-in-elastic-search/20236/3 "2014-10-15T07:12:36Z")

</div>

I have an experience to share with you guys. Once I was in a remote place, my signal in my phone got jammed, i thought the problem would be with my service provider. After coming back home i gave black and blues to my customer care highlighting my issue. They pleaded me saying that the problem is not with them. Then i browsed through the search engine regarding my issue, i got a remedy for my cell phone, there i came to know the problem called signal jamming that is experienced in most cell phones. They have a product called cell phone jammer could be very useful to get rid of these problems. Check out the details here **[Cell Phone Blockers](http://www.jammerfromchina.com/categories/Mobile_Phone_Jammers/)** and hope this information would be beneficial. Hope that u would pass this information to all your friends, so that they too would benefited, Stay safe, Cheers

---

<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 6, 2017, 12:56am UTC](https://discuss.elastic.co/t/need-help-to-create-array-type-field-in-elastic-search/20236/4 "2017-07-06T00:56:09Z")

</div>


