Compare a string and number in Scripted Field

Hey all,
I want to compare a string and an number (integer) inside a scripted field. I know I have to convert the field from string to integer. I just dont know the syntax for that and dont find any result.

The characters of String Field are all numbers so it should work if I get the syntax correct.

my current code:
{
"convert": {
"field" : "StringField",
"type": "integer"
}
}

doc['StringField'].value == doc['NumberField'].value

Thanks for help!

I created a scripted field of type: number and in the script I used a text field response.raw (which are http response code numbers but stored as text). And used Integer.parseInt on the doc value of it. When I go to Discover I see the numeric result for this scripted field. Does that help?

Regards,
Lee

I got a solution by myselfe, you can just parse it from Integer to String

e.g. :

doc['String.keyword'].value == " " + doc['Number'].value

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