I need this data in the same document. So this blocks are separated by '|' pipe shouldn't be splitted between document.
It could be a trivial case but I'm a fresh with ruby
Thanks in advance.
ruby {
code => '
f = event.get("value_field")
if f
fs = f.split("|")
fs.each_index{ |x|
fss = fs[x].split("-")
fss.each_index { |y|
event.set("#{(97 + y).chr}#{x+1}", fss[y])
}
}
end
'
}
In ASCII a/b/c/d/e are character codes 97/98/99/100/100. Ruby array indices start at zero, so for the first character of the field name we want to convert 97 plus the array index to a character, then we want to convert 1 plus the other index to a string....
@Badger One more thing, if I will provide in input mixed value for ex. string instead of number,
this arrays should be hash of array?
input: value_field = 5-7-10-none-9|5-7-9-disable-15|5-enable-9-14-15
So I've done some small exercise:
decomposes this field but in reverse order, something is not right here, and it does not spit out the string in the value
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.