# Range with text

**URL:** <https://discuss.elastic.co/t/range-with-text/133665>\
**Category:** Elasticsearch\
**Created:** [May 29, 2018, 10:56am UTC](https://discuss.elastic.co/t/range-with-text/133665 "2018-05-29T10:56:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Oullion](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_oullion/32/46106_2.png) [@Michael\_Oullion](https://discuss.elastic.co/u/Michael_Oullion)\
**Post date:** [May 29, 2018, 10:56am UTC](https://discuss.elastic.co/t/range-with-text/133665/1 "2018-05-29T10:56:15Z")

</div>

Hello,

I try to do a search with a range on text term.  
We have "box" that contain documents from "A0001" to "F235" and from "F236" to "P159",... for example and I need to find with box contained Bryan's Documents.

I found [here](https://www.elastic.co/guide/en/elasticsearch/reference/6.x/query-dsl-query-string-query.html#query-string-syntax) some examples but I can't do what i want.

In the Example,  
we can see :  
`tag:{alpha TO omega}`

but here we compare 1 field with 2 variables and I need to compare 1 variable to 2 fields, something like :  
`'N2345':{field1 TO field2}`.

So, I see **Ranges with one side unbounded** syntax :  
`age:>10 age:>=10 age:<10 age:<=10 age:(>=10 AND <20) age:(+>=10 +<20)`

I try but it doesn't seems to work :  
_existing value : **N21053** _  
Try :  
`(accountnumber:< 'N21079')` =\> 0 result  
`(accountnumber:>= 'N2105')` =\> return all

May I do something wrong?  
Is there a way to do this whit ELK?  
Any Ideas?

Regards,  
Mike

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 29, 2018, 11:20am UTC](https://discuss.elastic.co/t/range-with-text/133665/2 "2018-05-29T11:20:35Z")

</div>

It depends on the analyzer used on the field I guess.  
May be use a `keyword` datatype instead or a `keyword` analyzer.

---

<div class="post-metadata">

**Author:** ![Michael\_Oullion](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_oullion/32/46106_2.png) [@Michael\_Oullion](https://discuss.elastic.co/u/Michael_Oullion)\
**Post date:** [May 29, 2018, 11:43am UTC](https://discuss.elastic.co/t/range-with-text/133665/3 "2018-05-29T11:43:45Z")

</div>

Hi,  
Thanks for your quick answer.  
I try with `.keyword` but it doesn't change anything....  
But during this test, I found that I used a false syntax....

the right anwser was :  
`accountnumber:(+<N21058 +>=N2105)`

with no **'** or space  
So, even if it's was my mistake , your answer help to look it an other time and find it.  
Thanks.

---

<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:** [June 26, 2018, 11:43am UTC](https://discuss.elastic.co/t/range-with-text/133665/4 "2018-06-26T11:43:47Z")

</div>

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