# Range Query with % symbol

**URL:** <https://discuss.elastic.co/t/range-query-with-symbol/159699>\
**Category:** Elasticsearch\
**Created:** [December 6, 2018, 9:33am UTC](https://discuss.elastic.co/t/range-query-with-symbol/159699 "2018-12-06T09:33:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![infor.aldrin](https://avatars.discourse-cdn.com/v4/letter/i/8491ac/32.png) [@infor.aldrin](https://discuss.elastic.co/u/infor.aldrin)\
**Post date:** [December 6, 2018, 9:33am UTC](https://discuss.elastic.co/t/range-query-with-symbol/159699/1 "2018-12-06T09:33:04Z")

</div>

We would like to clarify regarding one of the functions of elastic search.  
[https://www.elastic.co/guide/en/elasticsearch/reference/6.2/query-dsl-query-string-query.html#\_ranges](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/query-dsl-query-string-query.html#_ranges)

According to the documentation, by using square brackets, `[]` , you’re searching inclusively.

Our sample queries were “[49% TO 90%]” AND “[50% TO 90%]”.  
But, when we ran the command, the record with 50% did not show on the first query.

 ![49TO90_2](https://us1.discourse-cdn.com/elastic/original/3X/e/2/e20483f91b1678b09fae14fd88616580d496e688.png)  
 ![50TO90_2](https://us1.discourse-cdn.com/elastic/original/3X/8/a/8a23c62fc1721ed7078b52f931f44e97e4c9c419.png)

---

<div class="post-metadata">

**Author:** ![klof](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/klof/32/31590_2.png) [@klof](https://discuss.elastic.co/u/klof)\
**Post date:** [December 6, 2018, 12:54pm UTC](https://discuss.elastic.co/t/range-query-with-symbol/159699/2 "2018-12-06T12:54:00Z")

</div>

By inserting the documents without specifying the datatype of the **field\_name** field in the mapping. Elasticsearch will create 2 versions of the field (text and keyword).

If you analyze the field\_name field with the value "50%", it's indexed as "50" (text type).  
So that means, to get the expected result, you should run the query, with the keyword version :

```
GET testing_with_percent/_search
{
  "query": {
    "query_string": {
      "query": "field_name.keyword: [50% TO 90%]"
    }
  }
}

```

or with the indexed values :

```
GET testing_with_percent/_search
{
  "query": {
    "query_string": {
      "query": "field_name: [50 TO 90]"
    }
  }
}
```

---

<div class="post-metadata">

**Author:** ![infor.aldrin](https://avatars.discourse-cdn.com/v4/letter/i/8491ac/32.png) [@infor.aldrin](https://discuss.elastic.co/u/infor.aldrin)\
**Post date:** [December 7, 2018, 7:45am UTC](https://discuss.elastic.co/t/range-query-with-symbol/159699/3 "2018-12-07T07:45:48Z")

</div>

Thank you, klof.

---

<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:** [January 4, 2019, 7:45am UTC](https://discuss.elastic.co/t/range-query-with-symbol/159699/4 "2019-01-04T07:45:56Z")

</div>

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