How to index json data into elasticsearch

let say I have json file with this type of data
{
"_id":1,
"cid":3067,
"name":"Tech Mahindra",
"type":[
"Information Technology and Services"
],
"empSize":99704,
"empSizeInfo":[
{
"on":1507141800,
"size":99704
}
],
"domain":"http://www.techmahindra.com/theme/DAVID.html",
"loc":{
"ct":"Maharashtra",
"cy":"in",
"pCode":"411004"
},
"followers":370803,
"ctdOn":1507141800,
"status":0,
"updtdOn":1507141800,
"cmptd":1
}
how to index data using logstash?

Does each file contain more than one such JSON object?

yes it will have a file like this
{
"_id":1,
"cid":2013,
"name":"nextGo",
"loc":{
"ct":"Maharashtra",
"cy":"in",
"pCode":"411004"
}
}{
"_id":2,
"cid":2014,
"name":"DealDollor",
"loc":{
"ct":"Andhra",
"cy":"in",
"pCode":"411034"
}
}
The file will be having multiple JSON objects ..

Okay. Logstash reads files line by line so you'll have to use a multiline codec to selectively join lines that are part of the same JSON object. This is going to be a bit tricky because of the }{ lines. I don't have time to give an example.

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