How to give customize name to fields and loop through logs

I have a log pattern like this

OTHERS|5HUNVWW|5HUNVWW|1469784588193|1469784588193|

these pipe separated values represent a key so I want to create fields like

field1 =  OTHERS
field2 =  5HUNVWW

and so on . How can I achieve this ?

filter {
  ruby {
    code => '
      ids = event["message"].split("|")
      ids.each_index { |i| event["field#{i}"] = ids[i] }
      end
    '
  }
}

I achieve it using this can anyone tell what will be the best logic to give customize name not like field1 and field2 it should be like firstname , lastname schoolname etc

You should be able to use the csv filter for this type of data.