Elasticsearch Scripting on Identical fields

I am using elasticsearch 6.2

My problem is
I have saved docs in a index with similar key and value names.
I want to filter contents using script query. Data is saved as

data:[{key:"howdy", value:"im good"},{key:"Size", value:2},{key:"City", value:"xyz"},{key:"areacode", value:1000}]
I want to filter records where size is gt 4, but the scripting query i am using throwing errors of casting datatypes.

I am specifically expecting to filter records where size is > number
field mappings are defined as below screenshot

Please do not post text in images. It is difficult to search and highlight in responses. Instead, use the </> icon to insert preformatted text.

Can you please show the actual search request you are making? It is unclear what your script source is. The error you appear to be getting would indicate a wrong type. Most likely your value field, as that is a keyword (ie string), but you are comparing it to 2, an integer.