Setting type in index or within an array?


(James Thornber) #1

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 :slight_smile:

Many thanks in advance,

james


(system) #2

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