# Logstash - csv with a json column - Add a new nested field from the existing field if it is integer

**URL:** <https://discuss.elastic.co/t/logstash-csv-with-a-json-column-add-a-new-nested-field-from-the-existing-field-if-it-is-integer/214967>\
**Category:** Logstash\
**Created:** [January 14, 2020, 9:32am UTC](https://discuss.elastic.co/t/logstash-csv-with-a-json-column-add-a-new-nested-field-from-the-existing-field-if-it-is-integer/214967 "2020-01-14T09:32:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lakshmi\_Narasimhan\_V](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lakshmi_narasimhan_v/32/48089_2.png) [@Lakshmi\_Narasimhan\_V](https://discuss.elastic.co/u/Lakshmi_Narasimhan_V)\
**Post date:** [January 14, 2020, 9:32am UTC](https://discuss.elastic.co/t/logstash-csv-with-a-json-column-add-a-new-nested-field-from-the-existing-field-if-it-is-integer/214967/1 "2020-01-14T09:32:44Z")

</div>

Below are the details: - CSV File,

visitid,labreport,  
11111,"[{""test"":""BUN"",""value"":""0.5""},{""test"":""Creatinie"",""value"":""0.8""},{""test"":""Potassium"",""value"":""3.5""}]",  
22222,"[{""test"":""BUN"",""value"":""1""},{""test"":""Creatinie"",""value"":""0.8""},{""test"":""Potassium"",""value"":""3.5""}]",  
33333,"[{""test"":""BUN"",""value"":""1""},{""test"":""Creatinie"",""value"":""0.8""},{""test"":""Potassium"",""value"":""3.5""}]",  
44444,"[{""test"":""BUN"",""value"":""1""},{""test"":""Creatinie"",""value"":""0.8""},{""test"":""Potassium"",""value"":""3.5""}]",  
55555,"[{""test"":""BUN"",""value"":""1""},{""test"":""Creatinie"",""value"":""0.8""},{""test"":""Potassium"",""value"":""3.5""}]",  
66666,"[{""test"":""BUN"",""value"":""1""},{""test"":""Creatinie"",""value"":""0.8""},{""test"":""Potassium"",""value"":""3.5""}]",

Index Mapping

PUT /test-index  
{  
"mappings" : {  
"properties" : {  
"visitid" : { "type" : "integer"},  
"labreport" : {  
"type" : "nested",  
"properties" : {  
"test" : { "type" : "text"},  
"value" : { "type" : "text" },  
"numValue" : { "type" : "text" }  
}  
}

```
    }
}

```

}

Logstash conf  
input {  
beats {  
host =\> "0.0.0.0"  
port =\> "5044"  
codec =\> "json"  
}  
}

filter {  
csv {  
skip\_header =\> "true"  
separator =\> ","  
columns =\> ["visitid","labreport"]  
}

json {  
source =\> "labreport"  
target =\> "labreport"  
}  
}

output {  
stdout {  
codec =\> json  
}  
elasticsearch {  
hosts =\> "[http://localhost:9200](http://localhost:9200)"  
index =\> "test-index"  
action =\> "update"  
doc\_as\_upsert =\> true  
document\_id =\> "%{visitid}"  
}  
}

What i wanted is i wanted to push the value of value column in the json to numValue in my nested mappings if it is a numeric field. i.e add a new field in the nested json array and copy the value to the new variable numValue only if the value is numeric ? Support please

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 11, 2020, 9:32am UTC](https://discuss.elastic.co/t/logstash-csv-with-a-json-column-add-a-new-nested-field-from-the-existing-field-if-it-is-integer/214967/2 "2020-02-11T09:32:46Z")

</div>

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