Hello,
I'm trying to add objets to an Array named "lineas". This is my initial document:
[quote="Alberto_Diaz, post:1, topic:105440, full:true"]
Hello,
I'm trying to add objets to an Array named "lineas". This is my initial document:
{
"lineas": [
],
"ticket": 4527,
"num_typett": 1,
"importe": 76.64,
"fecha_ticket": "2017-10-23T22:00:00.000Z",
"importe_servicios": 0,
"importe_sin_servicios": 76.64,
"fecha": "2017-10-23T22:00:00.000Z",
"hora_ticket": 203440,
"tienda": 4,
"@timestamp": "2017-10-27T10:30:26.206Z",
"num_bu": 2,
"@version": "1",
"mes": "10",
"id": "445271024102017",
"caja": 10,
"anio": "2017"
}
}
Then I try to update the object with this kibd of information from a sql:
------id-------------------------------linea
1----445271024102017-------{"numlig":[{"articulo":"13909154","cantidad":1.0000,"importe":5.1900}]}
2----445271024102017-------{"numlig":[{"articulo":"13823740","cantidad":1.0000,"importe":5.4500}]}
I want to add each new "linea" to "lineas"
I tried this but it doesn't work:
filter {
json {
    source => "linea"
  }
json {
    source => "lineas"
  }
}
output {
#stdout { codec => rubydebug }
  elasticsearch {
	hosts => "http://deslmelk01:9200"
	action => "update"
	index => "tickets-%{anio}.%{mes}"
	document_id => "%{id}"
	script_lang => "painless"
    script_type => "inline"  
	script => 'ctx._source.lineas.add("%{[numlig]}");'
  }
}
but I get an array of strings in "lineas" instead of an array of objetcs:
{
"lineas": [
"{importe_linea=5.1900, articulo=13909154, cantidad=1.0000}"
"{importe_linea=5.4500, articulo=13823740, cantidad=1.0000}",
],
"ticket": 4527,
"num_typett": 1,
"importe": 76.64,
"fecha_ticket": "2017-10-23T22:00:00.000Z",
"importe_servicios": 0,
"importe_sin_servicios": 76.64,
"fecha": "2017-10-23T22:00:00.000Z",
"hora_ticket": 203440,
"tienda": 4,
"@timestamp": "2017-10-27T10:30:26.206Z",
"num_bu": 2,
"@version": "1",
"mes": "10",
"id": "445271024102017",
"caja": 10,
"anio": "2017",
"numlig": [
{
"importe_linea": 4.59,
"articulo": "13607965",
"cantidad": 1
}
]
}
What am I doing wrong?
Thanks!