# Elastic String Length Issue

**URL:** https://discuss.elastic.co/t/elastic-string-length-issue/170710
**Category:** Elasticsearch
**Created:** [March 4, 2019, 10:55am UTC](https://discuss.elastic.co/t/elastic-string-length-issue/170710 "2019-03-04T10:55:26Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![vnitdeepak](https://avatars.discourse-cdn.com/v4/letter/v/9fc29f/32.png) [@vnitdeepak](https://discuss.elastic.co/u/vnitdeepak)
#### Post date: [March 4, 2019, 10:55am UTC](https://discuss.elastic.co/t/elastic-string-length-issue/170710/1 "2019-03-04T10:55:27Z")

</div>

This works  
GET indexname/\_search  
{  
"query": {  
"script": {  
"script": "doc['fieldName'].value?.length() ==3"  
}  
}  
}

But with \< and \> operator it does not work  
GET indexname/\_search  
{  
"query": {  
"script": {  
"script": "doc['fieldName'].value?.length() \> 3"  
}  
}  
}  
fieldName is of String Type.  
I am using ElasticSearch 5.3.

---

<div class="post-metadata">

### Author: ![glenacota](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/glenacota/32/41367_2.png) [@glenacota](https://discuss.elastic.co/u/glenacota)
#### Post date: [March 4, 2019, 1:50pm UTC](https://discuss.elastic.co/t/elastic-string-length-issue/170710/2 "2019-03-04T13:50:10Z")

</div>

Hi,  
it'd be helpful if you could tell us more about the problem occurring with the second query.  
Also, just to make it sure, the type of `fieldName` is `string` or `text`?

---

<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: [April 1, 2019, 1:50pm UTC](https://discuss.elastic.co/t/elastic-string-length-issue/170710/3 "2019-04-01T13:50:12Z")

</div>

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