Home > Net >  logstash input jdbc how to populate multi value field?
logstash input jdbc how to populate multi value field?

Time:11-13

I can put a doc with mulit value field tagids like this, but how to populate the field with multi value with logstash input jdbc.

PUT /song/_doc/0
{
  "artist_name":"test",
  "artistid":0,
  "categories":[4,5,6],
  "created_at":"2021-12-13T00:00:00Z",
  "name":"test",
  "name_pinyin":"csgq",
  "tagids":[1,2,3]
}

For now I use jdbc config, but it take 1,2,3 as one keyword. How to make it an array?

input {
  jdbc {
    jdbc_driver_library => ""
    jdbc_driver_class => "com.mysql.jdbc.Driver"
    jdbc_connection_string => "jdbc:............."
    jdbc_user => ""
    jdbc_password => ""
    schedule => "* * * * *"
    statement => "SELECT songid,name,name_pinyin,artistid,artist_name,'1,2,3' as tagids, '4,5,6' as categories,create_at from song"
  }
}

CodePudding user response:

You can leverage the mutate/split filter to achieve what you want:

filter {
  mutate {
     split => { 
        "categories" => "," 
        "tagids" => "," 
     }
  }
}
  • Related