# Setting type in index or within an array?

**URL:** <https://discuss.elastic.co/t/setting-type-in-index-or-within-an-array/152214>\
**Category:** Elasticsearch\
**Created:** [October 12, 2018, 9:59am UTC](https://discuss.elastic.co/t/setting-type-in-index-or-within-an-array/152214 "2018-10-12T09:59:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JamesTh](https://avatars.discourse-cdn.com/v4/letter/j/b2d939/32.png) [@JamesTh](https://discuss.elastic.co/u/JamesTh)\
**Post date:** [October 12, 2018, 9:59am UTC](https://discuss.elastic.co/t/setting-type-in-index-or-within-an-array/152214/1 "2018-10-12T09:59:03Z")

</div>

hi,

we have an array using Ruby that looks like this:

def filter(event)  
mymessage = event.get("message")  
lineArray = mymessage.scan(/LIN+(\d\*)++(\d\*)._\nQTY+21:(\d_)._\nPRI+[A-Z]_:(\d\*.?\d\*)'/)

finalArray = Array.new(lineArray.size)  
index = 0  
for matchArray in lineArray  
element = { "LINE\_NO" =\> matchArray[0],  
"ISBN" =\> matchArray[1],  
"QTY" =\> matchArray[2],  
"PRICE" =\> matchArray[3]  
}  
finalArray[index] = element  
index = index + 1  
end

event.set("order\_details\_array", finalArray)

return [event]  
end

The index looks like this:

"order\_details\_array": {  
"properties": {  
"ISBN": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"LINE\_NO": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"PRICE": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"QTY": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
}  
}  
},

It passes the values back correctly into elasticsearch, however, i'd like to be able to set Line\_NO, ISBN, QTY as a number. Should i do this within the array (and if so, how do I do this), or can i just update the index with the correct type attribute (and if so, how).

if you need anything else, please ask 🙂

Many thanks in advance,

james

---

<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:** [November 9, 2018, 9:59am UTC](https://discuss.elastic.co/t/setting-type-in-index-or-within-an-array/152214/2 "2018-11-09T09:59:06Z")

</div>

Closed on November 9, 2018, 9:59am UTC

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