# How can I query on a date range in an array...?

**URL:** <https://discuss.elastic.co/t/how-can-i-query-on-a-date-range-in-an-array/181267>\
**Category:** Elasticsearch\
**Created:** [May 15, 2019, 8:03pm UTC](https://discuss.elastic.co/t/how-can-i-query-on-a-date-range-in-an-array/181267 "2019-05-15T20:03:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cjokinen](https://avatars.discourse-cdn.com/v4/letter/c/cab0a1/32.png) [@cjokinen](https://discuss.elastic.co/u/cjokinen)\
**Post date:** [May 15, 2019, 8:03pm UTC](https://discuss.elastic.co/t/how-can-i-query-on-a-date-range-in-an-array/181267/1 "2019-05-15T20:03:44Z")

</div>

The format we are looking to load into elasticsearch is...

> \_source.publish\_date['timestamp'];

there is also a

> \_source.publish\_date['datetime'];

But I was trying to figure out how I could do a date range query on the timestamp.

If the timestamp was a simple field I think that the query might look like this (elasticsearch npm)

```
client.search({
 index: 'articles',
 type: '',
 body: {
   "query": {
     "range" : {
       "datetime" : {
         "gte": "2019-01-13||/d",
         "lte": "2019-03-14||/d",
         "format": "yyyy-MM-dd"
       }
     }
   }
 }
 
}).then(function(resp) {

```

but with the source data set as an array would it looks like this

```
"range" : {
       "publish_date['datetime']" : {
         "gte": "2019-01-13||/d",
         "lte": "2019-03-14||/d",
         "format": "yyyy-MM-dd"
       }
     }

```

---

<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 12, 2019, 8:03pm UTC](https://discuss.elastic.co/t/how-can-i-query-on-a-date-range-in-an-array/181267/2 "2019-06-12T20:03:45Z")

</div>

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