# Query match with range is not working

**URL:** <https://discuss.elastic.co/t/query-match-with-range-is-not-working/161450>\
**Category:** Elasticsearch\
**Created:** [December 19, 2018, 6:18am UTC](https://discuss.elastic.co/t/query-match-with-range-is-not-working/161450 "2018-12-19T06:18:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nayun\_oh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nayun_oh/32/46442_2.png) [@nayun\_oh](https://discuss.elastic.co/u/nayun_oh)\
**Post date:** [December 19, 2018, 6:18am UTC](https://discuss.elastic.co/t/query-match-with-range-is-not-working/161450/1 "2018-12-19T06:18:40Z")

</div>

![aa](https://us1.discourse-cdn.com/elastic/original/3X/6/3/6376bb8c9127c11e73a0c430ea02879387ffbfad.jpeg)

I find out that match with range query is not working.  
When I search data using range query, I can see "ACTION" text in payload field.  
But when I search data using both range and match, I can see empty result.  
Thank you in advance

---

<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:** [December 19, 2018, 7:04am UTC](https://discuss.elastic.co/t/query-match-with-range-is-not-working/161450/2 "2018-12-19T07:04:02Z")

</div>

Please don't post images of text as they are hardly readable and not searchable.

Instead paste the text and format it with `</>` icon. Check the preview window.

---

<div class="post-metadata">

**Author:** ![nayun\_oh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nayun_oh/32/46442_2.png) [@nayun\_oh](https://discuss.elastic.co/u/nayun_oh)\
**Post date:** [December 19, 2018, 8:31am UTC](https://discuss.elastic.co/t/query-match-with-range-is-not-working/161450/3 "2018-12-19T08:31:56Z")

</div>

{  
"query":{  
"bool":{  
"must":[  
{  
"match": {  
"service": "OG064301"  
}  
},  
{  
"match": {  
"payload": "ACTION"  
}  
}  
],  
"filter":[  
{  
"range":{  
"timestamp":{  
"lt":"2018-12-19T14:34:00.000Z",  
"gt":"2018-12-19T14:24:00.000Z"  
}  
}  
}  
]  
}  
}  
}

We use whitespace analyzer with lowercase filter on payload field.  
and we cannot search data using both range and match.

---

<div class="post-metadata">

**Author:** ![zz\_hello](https://avatars.discourse-cdn.com/v4/letter/z/3bc359/32.png) [@zz\_hello](https://discuss.elastic.co/u/zz_hello)\
**Post date:** [December 19, 2018, 8:41am UTC](https://discuss.elastic.co/t/query-match-with-range-is-not-working/161450/4 "2018-12-19T08:41:26Z")

</div>

maybe the problem is your service field

---

<div class="post-metadata">

**Author:** ![Bernt\_Rostad](https://avatars.discourse-cdn.com/v4/letter/b/3ab097/32.png) [@Bernt\_Rostad](https://discuss.elastic.co/u/Bernt_Rostad)\
**Post date:** [December 19, 2018, 8:46am UTC](https://discuss.elastic.co/t/query-match-with-range-is-not-working/161450/5 "2018-12-19T08:46:52Z")

</div>

> [@nayun\_oh](#):
>
> But when I search data using both range and match, I can see empty result.

Are you sure you have any results within that 10 minute date range?

I've been bitten by time zone and day light saving problems a few times, expecting certain documents but not finding them until I added an extra hour to the date range, so you may want to try that. At least just as a test of the range filter. For instance

```
"timestamp": {
    "lt": "2018-12-19T16:34:00.000Z",
    "gt": "2018-12-19T12:24:00.000Z"
}

```

If this turns out to be a question of different time zones, you will need to add the time zone info as part of the date range filter. For instance like this for a +2 hour shift:

```
"timestamp": {
    "lt": "2018-12-19T14:34:00+02:00",
    "gt": "2018-12-19T14:24:00+02:00"
}

```

---

<div class="post-metadata">

**Author:** ![nayun\_oh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nayun_oh/32/46442_2.png) [@nayun\_oh](https://discuss.elastic.co/u/nayun_oh)\
**Post date:** [December 21, 2018, 10:00am UTC](https://discuss.elastic.co/t/query-match-with-range-is-not-working/161450/6 "2018-12-21T10:00:08Z")

</div>

I am sure that date range is not a problem.

When I search for data using that date range, I can see 'ACTION' text in payload field.  
and When I only query data using "match": {  
"payload": "ACTION"  
}  
, I can see timestamp which has ""2018-12-19T14:25:00.000Z"

---

<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 18, 2019, 10:00am UTC](https://discuss.elastic.co/t/query-match-with-range-is-not-working/161450/7 "2019-01-18T10:00:13Z")

</div>

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