Jason Dinh
Jason Dinh

Reputation: 109

Need help parsing a csv JSON field to string with logstash

I am trying to upload a kaggle movie dataset using logstash into elasticsearch. The genres field is a stringified JSON object:

"genres" : "[{'id': 28, 'name': 'Action'}, {'id': 18, 'name': 'Drama'}, {'id': 9648, 'name': 'Mystery'}, {'id': 53, 'name': 'Thriller'}]"

Is it possible to transform the value from the above to an array like so using logstash?

"genres"; ["Action", "Drama", "Mystery", "Thriller"]

I tried using the json filter, but no luck.

filter {
  json {
    source => "genres"
  }
}

Upvotes: 1

Views: 182

Answers (1)

Trần Mạnh Cầm
Trần Mạnh Cầm

Reputation: 11

I think you should convert json string to object, then handle this object to new object and convert new object to new json string. Object: Gener { int id; string value; } Old Object: { List<Gener> geners } New Object: { List<string> geners }

Upvotes: 1

Related Questions