# Bug? when searching on int/double and date range combined

**URL:** <https://discuss.elastic.co/t/bug-when-searching-on-int-double-and-date-range-combined/60373>\
**Category:** Elasticsearch\
**Created:** [September 13, 2016, 11:34am UTC](https://discuss.elastic.co/t/bug-when-searching-on-int-double-and-date-range-combined/60373 "2016-09-13T11:34:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![barry1](https://avatars.discourse-cdn.com/v4/letter/b/7bcc69/32.png) [@barry1](https://discuss.elastic.co/u/barry1)\
**Post date:** [September 13, 2016, 11:34am UTC](https://discuss.elastic.co/t/bug-when-searching-on-int-double-and-date-range-combined/60373/1 "2016-09-13T11:34:44Z")

</div>

Hello,

I have a field "price" which is a double, and a field "insert\_date" which is a datetime field. When I do a range search on the price field all works fine, same goed for the insert\_date. But when I do a combined range search on both of then with the settings below I get an error.

```
bool: {
    must: [
        {
            range: {
                price: [
                    {
                        gte: "200"
                    },
                    {
                        lt: "600"
                    }
                ],
                insert_date: [
                    {
                        gte: "2016-09-13 05:01:14"
                    }
                ]
            }
        }
    ]
}

```

The error that i get is:

`Fatal error: Uncaught Elasticsearch\Common\Exceptions\BadRequest400Exception: {"error":{"root_cause":[{"type":"parse_exception","reason":"failed to parse date field [600] with format [yyyy-MM-dd HH:mm:ss]"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"init_scan","grouped":true,"failed_shards":[{"shard":0,"index":"data_standard_13_6_nl_test","node":"w115E6KmTiuBeW7RmJ_feQ","reason":{"type":"parse_exception","reason":"failed to parse date field [600] with format [yyyy-MM-dd HH:mm:ss]","caused_by":{"type":"illegal_argument_exception","reason":"Invalid format: \"600\" is too short"}}}]},"status":400}`

---

<div class="post-metadata">

**Author:** ![barry1](https://avatars.discourse-cdn.com/v4/letter/b/7bcc69/32.png) [@barry1](https://discuss.elastic.co/u/barry1)\
**Post date:** [September 13, 2016, 12:35pm UTC](https://discuss.elastic.co/t/bug-when-searching-on-int-double-and-date-range-combined/60373/2 "2016-09-13T12:35:10Z")

</div>

I managed to figure out a workaround by putting both fields in its own range. But I'm still wondering if this is a bug or a feature?

```
bool: {
    must: [
        {
            range: {
                price: {
                    gte: "200",
                    lt: "600"
                }
            }
        },
        {
            range: {
                insert_date: {
                    gte: "2016-09-13 05:01:14"
                }
            }
        }
    ]
}
```

---

<div class="post-metadata">

**Author:** ![jimczi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jimczi/32/47985_2.png) [@jimczi](https://discuss.elastic.co/u/jimczi)\
**Post date:** [September 13, 2016, 12:37pm UTC](https://discuss.elastic.co/t/bug-when-searching-on-int-double-and-date-range-combined/60373/3 "2016-09-13T12:37:09Z")

</div>

The range query can accept only one field/range, if you want to do two range queries you need to add a must clause:

````auto
{
   "query": {
      "bool": {
         "must": [
            {
               "range": {
                  "price": {
                     "gte": "200",
                     "lt": "600"
                  }
               }
            },
            {
               "range": {
                  "insert_date": {
                     "gte": "2016-09-13 05:01:14"
                  }
               }
            }
         ]
      }
   }
}
```
````

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [September 13, 2016, 12:53pm UTC](https://discuss.elastic.co/t/bug-when-searching-on-int-double-and-date-range-combined/60373/4 "2016-09-13T12:53:11Z")

</div>

I think this is a parsing bug - that first example should have had a more obvious error message. I've opened [an issue](https://github.com/elastic/elasticsearch/issues/20447) for it. @barry1, can you reply over there with the version of Elasticsearch you hit this issue in?

---

<div class="post-metadata">

**Author:** ![barry1](https://avatars.discourse-cdn.com/v4/letter/b/7bcc69/32.png) [@barry1](https://discuss.elastic.co/u/barry1)\
**Post date:** [September 13, 2016, 12:55pm UTC](https://discuss.elastic.co/t/bug-when-searching-on-int-double-and-date-range-combined/60373/5 "2016-09-13T12:55:04Z")

</div>

Great, thanks. I replied on the bug report.

---

<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 5, 2017, 10:20pm UTC](https://discuss.elastic.co/t/bug-when-searching-on-int-double-and-date-range-combined/60373/6 "2017-07-05T22:20:43Z")

</div>


