# Elasticsearch Scripting on Identical fields

**URL:** <https://discuss.elastic.co/t/elasticsearch-scripting-on-identical-fields/185174>\
**Category:** Elasticsearch\
**Created:** [June 11, 2019, 11:43am UTC](https://discuss.elastic.co/t/elasticsearch-scripting-on-identical-fields/185174 "2019-06-11T11:43:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shivi\_k](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@shivi\_k](https://discuss.elastic.co/u/shivi_k)\
**Post date:** [June 11, 2019, 11:43am UTC](https://discuss.elastic.co/t/elasticsearch-scripting-on-identical-fields/185174/1 "2019-06-11T11:43:54Z")

</div>

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.

 ![cap2](https://us1.discourse-cdn.com/elastic/original/3X/5/c/5c21dc19b032daadb23f94cc02078acfc5af242a.png)

 ![capture](https://us1.discourse-cdn.com/elastic/original/3X/2/9/29a59058621db687fcc726f9960e6054dc1f3b37.png)

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

 ![field_mappings](https://us1.discourse-cdn.com/elastic/original/3X/5/7/57786a95bfd7eff5faf4c30b0b41cf9486cacab8.png)

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [June 14, 2019, 4:39pm UTC](https://discuss.elastic.co/t/elasticsearch-scripting-on-identical-fields/185174/2 "2019-06-14T16:39:17Z")

</div>

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.

---

<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:** [July 12, 2019, 4:39pm UTC](https://discuss.elastic.co/t/elasticsearch-scripting-on-identical-fields/185174/3 "2019-07-12T16:39:17Z")

</div>

Closed on July 12, 2019, 4:39pm UTC

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