Hi,
Using Elasticsearch 6.5.1
I tried to set a value using set and my new value become a string:
Here my debug simulate:
POST _ingest/pipeline/_simulate
{
"pipeline" : {
"description": "debug",
"processors": [
{
"set": {
"field": "end_int",
"value": "(int){{end}}"
}
},
{
"set": {
"if": "ctx.end > 2400;",
"field": "result",
"value": "Big"
}
},
{
"set": {
"if": "ctx.end_int < 2400;",
"field": "result",
"value": "Small"
}
},
{
"remove": {
"field": "end_int"
}
}
]},
"docs": [
{
"_index": "banana",
"_type": "_doc",
"_id": "125468",
"_score": 1,
"_source": {
"end": 2000
}
}
]
}
And it crash on the second condition the first condition is ok as end is integer but the one I set became a string...
"script_stack" : [
"ctx.end_int < 2400;",
" ^---- HERE"
],
"script" : "ctx.end_int < 2400;",
"lang" : "painless",
"caused_by" : {
"type" : "class_cast_exception",
"reason" : "Cannot apply [<] operation to types [java.lang.String] and [java.lang.Integer]."
}
How can I keep the integer type when I use set?
As you can see in the simulate I add (int) but it not affect.
Only way to make it work is using convert
"processors": [
{
"set": {
"field": "end_int",
"value": "{{end}}"
}
},
{
"convert" : {
"field" : "end_int",
"type": "integer"
}
},
....
If I set an integer I expect that my value stay integer. Did I mistake in the set definition?
Merry christmas.
Thanks.