# Date range query ignore month

**URL:** <https://discuss.elastic.co/t/date-range-query-ignore-month/17281>\
**Category:** Elasticsearch\
**Created:** [April 30, 2014, 1:28pm UTC](https://discuss.elastic.co/t/date-range-query-ignore-month/17281 "2014-04-30T13:28:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![fatih](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fatih/32/1433_2.png) [@fatih](https://discuss.elastic.co/u/fatih)\
**Post date:** [April 30, 2014, 1:28pm UTC](https://discuss.elastic.co/t/date-range-query-ignore-month/17281/1 "2014-04-30T13:28:16Z")

</div>

Hi guys,

I've been using Elasticsearch as my data store and I got lots of documents  
in it. My problem is, I figured it out that Elasticsearch does ignore month  
field regarding mapping and I can not get real search response.

Here is what I have in my index and my query, please tell me if I'm wrong:

curl -XPUT '[http://localhost:9200/tt6/](http://localhost:9200/tt6/)' -d '{}'  
curl -XPUT '[http://localhost:9200/tt6/tweet/\_mapping](http://localhost:9200/tt6/tweet/_mapping)' -d '{"tweet" :  
{"properties" : {"date" : {"type" : "date", "format": "YYYY-MM-DD HH:mm:ss"  
}}}}'  
curl -XPUT '[http://localhost:9200/tt6/tweet/1](http://localhost:9200/tt6/tweet/1)' -d '{"date": "2014-02-14  
04:00:45"}'

curl -XGET '[http://localhost:9200/tt6/\_search](http://localhost:9200/tt6/_search)' -d '  
{  
"query": {  
"bool": {  
"must": [  
{  
"range": {  
"tweet.date": {  
"from": "2014-12-01 00:00:00",  
"to": "2014-12-30 00:00:00"  
}  
}  
}  
],  
"must\_not": [],  
"should": []  
}  
},  
"from": 0,  
"size": 10,  
"sort": [],  
"facets": {}  
}'

And my response is  
{  
"took": 3,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 1,  
"max\_score": 1,  
"hits": [  
{  
"\_index": "tt6",  
"\_type": "tweet",  
"\_id": "1",  
"\_score": 1,  
"\_source": {  
"date": "2014-02-14 04:00:45",  
"name": "test"  
}  
}  
]  
}  
}

By given date range it must has no response beet 1st of December 2014 and  
30th of December 2014, but it returns.

Any help will be appreciated.

Regards.

Fatih.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/6ee655cf-9e77-439f-9aac-8255efafcb2a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6ee655cf-9e77-439f-9aac-8255efafcb2a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Umut\_Yerci](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/umut_yerci/32/1253_2.png) [@Umut\_Yerci](https://discuss.elastic.co/u/Umut_Yerci)\
**Post date:** [May 2, 2014, 5:43am UTC](https://discuss.elastic.co/t/date-range-query-ignore-month/17281/2 "2014-05-02T05:43:10Z")

</div>

Yes, I was faced same problem in my db. After that I tried these code. I  
think XGET reqeusts' query does not work well.

On Wednesday, April 30, 2014 4:28:16 PM UTC+3, Fatih Karatana wrote:

> Hi guys,
> 
> I've been using Elasticsearch as my data store and I got lots of  
> documents in it. My problem is, I figured it out that Elasticsearch does  
> ignore month field regarding mapping and I can not get real search  
> response.
> 
> Here is what I have in my index and my query, please tell me if I'm wrong:
> 
> curl -XPUT '[http://localhost:9200/tt6/](http://localhost:9200/tt6/)' -d '{}'  
> curl -XPUT '[http://localhost:9200/tt6/tweet/\_mapping](http://localhost:9200/tt6/tweet/_mapping)' -d '{"tweet" :  
> {"properties" : {"date" : {"type" : "date", "format": "YYYY-MM-DD HH:mm:ss"  
> }}}}'  
> curl -XPUT '[http://localhost:9200/tt6/tweet/1](http://localhost:9200/tt6/tweet/1)' -d '{"date": "2014-02-14  
> 04:00:45"}'
> 
> curl -XGET '[http://localhost:9200/tt6/\_search](http://localhost:9200/tt6/_search)' -d '  
> {  
> "query": {  
> "bool": {  
> "must": [  
> {  
> "range": {  
> "tweet.date": {  
> "from": "2014-12-01 00:00:00",  
> "to": "2014-12-30 00:00:00"  
> }  
> }  
> }  
> ],  
> "must\_not": ,  
> "should":   
> }  
> },  
> "from": 0,  
> "size": 10,  
> "sort": ,  
> "facets": {}  
> }'
> 
> And my response is  
> {  
> "took": 3,  
> "timed\_out": false,  
> "\_shards": {  
> "total": 5,  
> "successful": 5,  
> "failed": 0  
> },  
> "hits": {  
> "total": 1,  
> "max\_score": 1,  
> "hits": [  
> {  
> "\_index": "tt6",  
> "\_type": "tweet",  
> "\_id": "1",  
> "\_score": 1,  
> "\_source": {  
> "date": "2014-02-14 04:00:45",  
> "name": "test"  
> }  
> }  
> ]  
> }  
> }
> 
> By given date range it must has no response beet 1st of December 2014 and  
> 30th of December 2014, but it returns.
> 
> Any help will be appreciated.
> 
> Regards.
> 
> Fatih.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/7393b6eb-ddcc-406d-b560-ee196aeaed74%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7393b6eb-ddcc-406d-b560-ee196aeaed74%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![eunever32](https://avatars.discourse-cdn.com/v4/letter/e/e68b1a/32.png) [@eunever32](https://discuss.elastic.co/u/eunever32)\
**Post date:** [August 7, 2014, 10:04pm UTC](https://discuss.elastic.co/t/date-range-query-ignore-month/17281/3 "2014-08-07T22:04:24Z")

</div>

Hi

I don't see the answer from the second post ?

I have the same problem :

PUT tweet  
PUT tweet/tweet/\_mapping  
{  
"tweet" : {  
"\_timestamp" : {  
"enabled" : true,  
"path" : "post\_date",  
"type" : "date",  
"format" : "yyyy-MM-dd HH:mm:ss"  
}  
}  
}  
PUT tweet/tweet/1  
{  
"field1": "value",  
"post\_date": "2009-11-15 14:12:12"  
}  
PUT tweet/tweet/3  
{  
"field1": "value",  
"post\_date": "2009-09-15 14:12:12"  
}  
PUT tweet/tweet/2  
{  
"field1": "value",  
"post\_date": "2009-10-15 14:12:12"  
}  
PUT tweet/tweet/1  
{  
"field1": "value",  
"post\_date": "2009-11-15 14:12:12"  
}

Neither of these queries returns any documents : seems that any date with  
year 2009 is considered outside the range

GET tweet/\_search  
{  
"query": {  
"range": {  
"post\_date": {  
"from": "2009-01-01",  
"to": "2009-12-01"  
}  
}  
}  
}  
GET /tweet/\_search  
{  
"query" : {  
"filtered" : {  
"filter" : {  
"range" : {  
"post\_date" : {  
"gte" : "2009-01-01",  
"lt" : "2009-12-31"  
}  
}  
}  
}  
}  
}

On Wednesday, April 30, 2014 2:28:16 PM UTC+1, Fatih Karatana wrote:

> Hi guys,
> 
> I've been using Elasticsearch as my data store and I got lots of  
> documents in it. My problem is, I figured it out that Elasticsearch does  
> ignore month field regarding mapping and I can not get real search  
> response.
> 
> Here is what I have in my index and my query, please tell me if I'm wrong:
> 
> curl -XPUT '[http://localhost:9200/tt6/](http://localhost:9200/tt6/)' -d '{}'  
> curl -XPUT '[http://localhost:9200/tt6/tweet/\_mapping](http://localhost:9200/tt6/tweet/_mapping)' -d '{"tweet" :  
> {"properties" : {"date" : {"type" : "date", "format": "YYYY-MM-DD HH:mm:ss"  
> }}}}'  
> curl -XPUT '[http://localhost:9200/tt6/tweet/1](http://localhost:9200/tt6/tweet/1)' -d '{"date": "2014-02-14  
> 04:00:45"}'
> 
> curl -XGET '[http://localhost:9200/tt6/\_search](http://localhost:9200/tt6/_search)' -d '  
> {  
> "query": {  
> "bool": {  
> "must": [  
> {  
> "range": {  
> "tweet.date": {  
> "from": "2014-12-01 00:00:00",  
> "to": "2014-12-30 00:00:00"  
> }  
> }  
> }  
> ],  
> "must\_not": ,  
> "should":   
> }  
> },  
> "from": 0,  
> "size": 10,  
> "sort": ,  
> "facets": {}  
> }'
> 
> And my response is  
> {  
> "took": 3,  
> "timed\_out": false,  
> "\_shards": {  
> "total": 5,  
> "successful": 5,  
> "failed": 0  
> },  
> "hits": {  
> "total": 1,  
> "max\_score": 1,  
> "hits": [  
> {  
> "\_index": "tt6",  
> "\_type": "tweet",  
> "\_id": "1",  
> "\_score": 1,  
> "\_source": {  
> "date": "2014-02-14 04:00:45",  
> "name": "test"  
> }  
> }  
> ]  
> }  
> }
> 
> By given date range it must has no response beet 1st of December 2014 and  
> 30th of December 2014, but it returns.
> 
> Any help will be appreciated.
> 
> Regards.
> 
> Fatih.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/9d494ca7-523e-467f-886a-0fe04e9e1223%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9d494ca7-523e-467f-886a-0fe04e9e1223%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [August 7, 2014, 10:14pm UTC](https://discuss.elastic.co/t/date-range-query-ignore-month/17281/4 "2014-08-07T22:14:14Z")

</div>

I might be wrong but you did not define any mapping for the post\_date field itself.  
I guess it could be the cause here. So your post\_date field is a String with a standard analyzer which produce 2009 as one of the token.

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 8 août 2014 à 00:04:27, [eunever32@gmail.com](mailto:eunever32@gmail.com) ([eunever32@gmail.com](mailto:eunever32@gmail.com)) a écrit:

Hi

I don't see the answer from the second post ?

I have the same problem :

PUT tweet  
PUT tweet/tweet/\_mapping  
{  
"tweet" : {  
"\_timestamp" : {  
"enabled" : true,  
"path" : "post\_date",  
"type" : "date",  
"format" : "yyyy-MM-dd HH:mm:ss"  
}  
}  
}  
PUT tweet/tweet/1  
{  
"field1": "value",  
"post\_date": "2009-11-15 14:12:12"  
}  
PUT tweet/tweet/3  
{  
"field1": "value",  
"post\_date": "2009-09-15 14:12:12"  
}  
PUT tweet/tweet/2  
{  
"field1": "value",  
"post\_date": "2009-10-15 14:12:12"  
}  
PUT tweet/tweet/1  
{  
"field1": "value",  
"post\_date": "2009-11-15 14:12:12"  
}

Neither of these queries returns any documents : seems that any date with year 2009 is considered outside the range

GET tweet/\_search  
{  
"query": {  
"range": {  
"post\_date": {  
"from": "2009-01-01",  
"to": "2009-12-01"  
}  
}  
}  
}  
GET /tweet/\_search  
{  
"query" : {  
"filtered" : {  
"filter" : {  
"range" : {  
"post\_date" : {  
"gte" : "2009-01-01",  
"lt" : "2009-12-31"  
}  
}  
}  
}  
}  
}

On Wednesday, April 30, 2014 2:28:16 PM UTC+1, Fatih Karatana wrote:  
Hi guys,

I've been using Elasticsearch as my data store and I got lots of documents in it. My problem is, I figured it out that Elasticsearch does ignore month field regarding mapping and I can not get real search response.

Here is what I have in my index and my query, please tell me if I'm wrong:

curl -XPUT '[http://localhost:9200/tt6/](http://localhost:9200/tt6/)' -d '{}'  
curl -XPUT '[http://localhost:9200/tt6/tweet/\_mapping](http://localhost:9200/tt6/tweet/_mapping)' -d '{"tweet" : {"properties" : {"date" : {"type" : "date", "format": "YYYY-MM-DD HH:mm:ss" }}}}'  
curl -XPUT '[http://localhost:9200/tt6/tweet/1](http://localhost:9200/tt6/tweet/1)' -d '{"date": "2014-02-14 04:00:45"}'

curl -XGET '[http://localhost:9200/tt6/\_search](http://localhost:9200/tt6/_search)' -d '  
{  
"query": {  
"bool": {  
"must": [  
{  
"range": {  
"tweet.date": {  
"from": "2014-12-01 00:00:00",  
"to": "2014-12-30 00:00:00"  
}  
}  
}  
],  
"must\_not": [],  
"should": []  
}  
},  
"from": 0,  
"size": 10,  
"sort": [],  
"facets": {}  
}'

And my response is  
{  
"took": 3,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 1,  
"max\_score": 1,  
"hits": [  
{  
"\_index": "tt6",  
"\_type": "tweet",  
"\_id": "1",  
"\_score": 1,  
"\_source": {  
"date": "2014-02-14 04:00:45",  
"name": "test"  
}  
}  
]  
}  
}

By given date range it must has no response beet 1st of December 2014 and 30th of December 2014, but it returns.

Any help will be appreciated.

Regards.

## Fatih.

You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/9d494ca7-523e-467f-886a-0fe04e9e1223%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9d494ca7-523e-467f-886a-0fe04e9e1223%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/etPan.53e3fa36.216231b.18f0%40MacBook-Air-de-David.local](https://groups.google.com/d/msgid/elasticsearch/etPan.53e3fa36.216231b.18f0%40MacBook-Air-de-David.local).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![eunever32](https://avatars.discourse-cdn.com/v4/letter/e/e68b1a/32.png) [@eunever32](https://discuss.elastic.co/u/eunever32)\
**Post date:** [August 8, 2014, 12:16am UTC](https://discuss.elastic.co/t/date-range-query-ignore-month/17281/5 "2014-08-08T00:16:14Z")

</div>

Thanks David

So I tried to define the post\_date field of type date

and then put the document with the post\_date, hoping it would store the  
timestamp.

PUT tweet/tweet/\_mapping  
{  
"tweet" : {

```
    "_timestamp" : {
        "enabled" : true,
        "path" : "post_date"
    }, 
    "properties" : {
        "post_date" : {"type" : "date"},
        "priority" : {"type" : "integer"},
        "rank" : {"type" : "float"}
    }
    
}

```

}  
PUT tweet/tweet/1  
{  
"post\_date": "2009-11-15"  
}

I tried various values for post\_date but always getting this error:

{  
"error": "ElasticsearchParseException[failed to parse doc to extract  
routing/timestamp/id]; nested: TimestampParsingException[failed to parse  
timestamp [2009-11-15]]; ",  
"status": 400  
}

any assistance appreciated

On Thursday, August 7, 2014 11:14:30 PM UTC+1, David Pilato wrote:

> I might be wrong but you did not define any mapping for the post\_date  
> field itself.  
> I guess it could be the cause here. So your post\_date field is a String  
> with a standard analyzer which produce 2009 as one of the token.
> 
> --  
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr  
> [https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)
> 
> Le 8 août 2014 à 00:04:27, [eune...@gmail.com](mailto:eune...@gmail.com) \<javascript:\> (  
> [eune...@gmail.com](mailto:eune...@gmail.com) \<javascript:\>) a écrit:
> 
> Hi
> 
> I don't see the answer from the second post ?
> 
> I have the same problem :
> 
> PUT tweet  
> PUT tweet/tweet/\_mapping  
> {  
> "tweet" : {  
> "\_timestamp" : {  
> "enabled" : true,  
> "path" : "post\_date",  
> "type" : "date",  
> "format" : "yyyy-MM-dd HH:mm:ss"  
> }  
> }  
> }  
> PUT tweet/tweet/1  
> {  
> "field1": "value",  
> "post\_date": "2009-11-15 14:12:12"  
> }  
> PUT tweet/tweet/3  
> {  
> "field1": "value",  
> "post\_date": "2009-09-15 14:12:12"  
> }  
> PUT tweet/tweet/2  
> {  
> "field1": "value",  
> "post\_date": "2009-10-15 14:12:12"  
> }  
> PUT tweet/tweet/1  
> {  
> "field1": "value",  
> "post\_date": "2009-11-15 14:12:12"  
> }
> 
> Neither of these queries returns any documents : seems that any date with  
> year 2009 is considered outside the range
> 
> GET tweet/\_search  
> {  
> "query": {  
> "range": {  
> "post\_date": {  
> "from": "2009-01-01",  
> "to": "2009-12-01"  
> }  
> }  
> }  
> }  
> GET /tweet/\_search  
> {  
> "query" : {  
> "filtered" : {  
> "filter" : {  
> "range" : {  
> "post\_date" : {  
> "gte" : "2009-01-01",  
> "lt" : "2009-12-31"  
> }  
> }  
> }  
> }  
> }  
> }
> 
> On Wednesday, April 30, 2014 2:28:16 PM UTC+1, Fatih Karatana wrote:
> 
> > Hi guys,
> > 
> > I've been using Elasticsearch as my data store and I got lots of  
> > documents in it. My problem is, I figured it out that Elasticsearch does  
> > ignore month field regarding mapping and I can not get real search response.
> > 
> > Here is what I have in my index and my query, please tell me if I'm wrong:
> > 
> > curl -XPUT '[http://localhost:9200/tt6/](http://localhost:9200/tt6/)' -d '{}'  
> > curl -XPUT '[http://localhost:9200/tt6/tweet/\_mapping](http://localhost:9200/tt6/tweet/_mapping)' -d '{"tweet" :  
> > {"properties" : {"date" : {"type" : "date", "format": "YYYY-MM-DD HH:mm:ss"  
> > }}}}'  
> > curl -XPUT '[http://localhost:9200/tt6/tweet/1](http://localhost:9200/tt6/tweet/1)' -d '{"date": "2014-02-14  
> > 04:00:45"}'
> > 
> > curl -XGET '[http://localhost:9200/tt6/\_search](http://localhost:9200/tt6/_search)' -d '  
> > {  
> > "query": {  
> > "bool": {  
> > "must": [  
> > {  
> > "range": {  
> > "tweet.date": {  
> > "from": "2014-12-01 00:00:00",  
> > "to": "2014-12-30 00:00:00"  
> > }  
> > }  
> > }  
> > ],  
> > "must\_not": ,  
> > "should":   
> > }  
> > },  
> > "from": 0,  
> > "size": 10,  
> > "sort": ,  
> > "facets": {}  
> > }'
> > 
> > And my response is  
> > {  
> > "took": 3,  
> > "timed\_out": false,  
> > "\_shards": {  
> > "total": 5,  
> > "successful": 5,  
> > "failed": 0  
> > },  
> > "hits": {  
> > "total": 1,  
> > "max\_score": 1,  
> > "hits": [  
> > {  
> > "\_index": "tt6",  
> > "\_type": "tweet",  
> > "\_id": "1",  
> > "\_score": 1,  
> > "\_source": {  
> > "date": "2014-02-14 04:00:45",  
> > "name": "test"  
> > }  
> > }  
> > ]  
> > }  
> > }
> > 
> > By given date range it must has no response beet 1st of December 2014 and  
> > 30th of December 2014, but it returns.
> > 
> > Any help will be appreciated.
> > 
> > Regards.
> > 
> > Fatih.
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/9d494ca7-523e-467f-886a-0fe04e9e1223%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9d494ca7-523e-467f-886a-0fe04e9e1223%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/9d494ca7-523e-467f-886a-0fe04e9e1223%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/9d494ca7-523e-467f-886a-0fe04e9e1223%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/a040b389-2516-46e3-9559-8968955f42d0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a040b389-2516-46e3-9559-8968955f42d0%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![eunever32](https://avatars.discourse-cdn.com/v4/letter/e/e68b1a/32.png) [@eunever32](https://discuss.elastic.co/u/eunever32)\
**Post date:** [August 8, 2014, 12:30am UTC](https://discuss.elastic.co/t/date-range-query-ignore-month/17281/6 "2014-08-08T00:30:47Z")

</div>

Hey it works: I just defined type "date" no special formatting  
I couldn't get the \_timestamp to work!

But when I just use post\_date: date and inserted a valid date it worked.

Thanks!

On Friday, August 8, 2014 1:16:14 AM UTC+1, [eune...@gmail.com](mailto:eune...@gmail.com) wrote:

> Thanks David
> 
> So I tried to define the post\_date field of type date
> 
> and then put the document with the post\_date, hoping it would store the  
> timestamp.
> 
> PUT tweet/tweet/\_mapping  
> {  
> "tweet" : {
> 
> ```
> "_timestamp" : {
> "enabled" : true,
> "path" : "post_date"
> }, 
> "properties" : {
> "post_date" : {"type" : "date"},
> "priority" : {"type" : "integer"},
> "rank" : {"type" : "float"}
> }
>     
> }
> 
> ```
> 
> }  
> PUT tweet/tweet/1  
> {  
> "post\_date": "2009-11-15"  
> }
> 
> I tried various values for post\_date but always getting this error:
> 
> {  
> "error": "ElasticsearchParseException[failed to parse doc to extract  
> routing/timestamp/id]; nested: TimestampParsingException[failed to parse  
> timestamp [2009-11-15]]; ",  
> "status": 400  
> }
> 
> any assistance appreciated
> 
> On Thursday, August 7, 2014 11:14:30 PM UTC+1, David Pilato wrote:
> 
> > I might be wrong but you did not define any mapping for the post\_date  
> > field itself.  
> > I guess it could be the cause here. So your post\_date field is a String  
> > with a standard analyzer which produce 2009 as one of the token.
> > 
> > --  
> > _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> > @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr  
> > [https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)
> > 
> > Le 8 août 2014 à 00:04:27, [eune...@gmail.com](mailto:eune...@gmail.com) ([eune...@gmail.com](mailto:eune...@gmail.com)) a écrit:
> > 
> > Hi
> > 
> > I don't see the answer from the second post ?
> > 
> > I have the same problem :
> > 
> > PUT tweet  
> > PUT tweet/tweet/\_mapping  
> > {  
> > "tweet" : {  
> > "\_timestamp" : {  
> > "enabled" : true,  
> > "path" : "post\_date",  
> > "type" : "date",  
> > "format" : "yyyy-MM-dd HH:mm:ss"  
> > }  
> > }  
> > }  
> > PUT tweet/tweet/1  
> > {  
> > "field1": "value",  
> > "post\_date": "2009-11-15 14:12:12"  
> > }  
> > PUT tweet/tweet/3  
> > {  
> > "field1": "value",  
> > "post\_date": "2009-09-15 14:12:12"  
> > }  
> > PUT tweet/tweet/2  
> > {  
> > "field1": "value",  
> > "post\_date": "2009-10-15 14:12:12"  
> > }  
> > PUT tweet/tweet/1  
> > {  
> > "field1": "value",  
> > "post\_date": "2009-11-15 14:12:12"  
> > }
> > 
> > Neither of these queries returns any documents : seems that any date with  
> > year 2009 is considered outside the range
> > 
> > GET tweet/\_search  
> > {  
> > "query": {  
> > "range": {  
> > "post\_date": {  
> > "from": "2009-01-01",  
> > "to": "2009-12-01"  
> > }  
> > }  
> > }  
> > }  
> > GET /tweet/\_search  
> > {  
> > "query" : {  
> > "filtered" : {  
> > "filter" : {  
> > "range" : {  
> > "post\_date" : {  
> > "gte" : "2009-01-01",  
> > "lt" : "2009-12-31"  
> > }  
> > }  
> > }  
> > }  
> > }  
> > }
> > 
> > On Wednesday, April 30, 2014 2:28:16 PM UTC+1, Fatih Karatana wrote:
> > 
> > > Hi guys,
> > > 
> > > I've been using Elasticsearch as my data store and I got lots of  
> > > documents in it. My problem is, I figured it out that Elasticsearch does  
> > > ignore month field regarding mapping and I can not get real search response.
> > > 
> > > Here is what I have in my index and my query, please tell me if I'm  
> > > wrong:
> > > 
> > > curl -XPUT '[http://localhost:9200/tt6/](http://localhost:9200/tt6/)' -d '{}'  
> > > curl -XPUT '[http://localhost:9200/tt6/tweet/\_mapping](http://localhost:9200/tt6/tweet/_mapping)' -d '{"tweet" :  
> > > {"properties" : {"date" : {"type" : "date", "format": "YYYY-MM-DD HH:mm:ss"  
> > > }}}}'  
> > > curl -XPUT '[http://localhost:9200/tt6/tweet/1](http://localhost:9200/tt6/tweet/1)' -d '{"date": "2014-02-14  
> > > 04:00:45"}'
> > > 
> > > curl -XGET '[http://localhost:9200/tt6/\_search](http://localhost:9200/tt6/_search)' -d '  
> > > {  
> > > "query": {  
> > > "bool": {  
> > > "must": [  
> > > {  
> > > "range": {  
> > > "tweet.date": {  
> > > "from": "2014-12-01 00:00:00",  
> > > "to": "2014-12-30 00:00:00"  
> > > }  
> > > }  
> > > }  
> > > ],  
> > > "must\_not": ,  
> > > "should":   
> > > }  
> > > },  
> > > "from": 0,  
> > > "size": 10,  
> > > "sort": ,  
> > > "facets": {}  
> > > }'
> > > 
> > > And my response is  
> > > {  
> > > "took": 3,  
> > > "timed\_out": false,  
> > > "\_shards": {  
> > > "total": 5,  
> > > "successful": 5,  
> > > "failed": 0  
> > > },  
> > > "hits": {  
> > > "total": 1,  
> > > "max\_score": 1,  
> > > "hits": [  
> > > {  
> > > "\_index": "tt6",  
> > > "\_type": "tweet",  
> > > "\_id": "1",  
> > > "\_score": 1,  
> > > "\_source": {  
> > > "date": "2014-02-14 04:00:45",  
> > > "name": "test"  
> > > }  
> > > }  
> > > ]  
> > > }  
> > > }
> > > 
> > > By given date range it must has no response beet 1st of December 2014  
> > > and 30th of December 2014, but it returns.
> > > 
> > > Any help will be appreciated.
> > > 
> > > Regards.
> > > 
> > > Fatih.
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/9d494ca7-523e-467f-886a-0fe04e9e1223%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9d494ca7-523e-467f-886a-0fe04e9e1223%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/9d494ca7-523e-467f-886a-0fe04e9e1223%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/9d494ca7-523e-467f-886a-0fe04e9e1223%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/d1b04f1c-3c0d-4902-ab85-7041823b760c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d1b04f1c-3c0d-4902-ab85-7041823b760c%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [August 8, 2014, 5:55am UTC](https://discuss.elastic.co/t/date-range-query-ignore-month/17281/7 "2014-08-08T05:55:15Z")

</div>

Apply the same format for both \_timestamp and post\_date. This should work.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 8 août 2014 à 02:16, [eunever32@gmail.com](mailto:eunever32@gmail.com) a écrit :

Thanks David

So I tried to define the post\_date field of type date

and then put the document with the post\_date, hoping it would store the timestamp.

PUT tweet/tweet/\_mapping  
{  
"tweet" : {

```
    "_timestamp" : {
        "enabled" : true,
        "path" : "post_date"
    }, 
    "properties" : {
        "post_date" : {"type" : "date"},
        "priority" : {"type" : "integer"},
        "rank" : {"type" : "float"}
    }
    
}

```

}  
PUT tweet/tweet/1  
{  
"post\_date": "2009-11-15"  
}

I tried various values for post\_date but always getting this error:

{  
"error": "ElasticsearchParseException[failed to parse doc to extract routing/timestamp/id]; nested: TimestampParsingException[failed to parse timestamp [2009-11-15]]; ",  
"status": 400  
}

any assistance appreciated

> On Thursday, August 7, 2014 11:14:30 PM UTC+1, David Pilato wrote:  
> I might be wrong but you did not define any mapping for the post\_date field itself.  
> I guess it could be the cause here. So your post\_date field is a String with a standard analyzer which produce 2009 as one of the token.
> 
> --  
> David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
> @dadoonet | @elasticsearchfr
> 
> > Le 8 août 2014 à 00:04:27, [eune...@gmail.com](mailto:eune...@gmail.com) ([eune...@gmail.com](mailto:eune...@gmail.com)) a écrit:
> > 
> > Hi
> > 
> > I don't see the answer from the second post ?
> > 
> > I have the same problem :
> > 
> > PUT tweet  
> > PUT tweet/tweet/\_mapping  
> > {  
> > "tweet" : {  
> > "\_timestamp" : {  
> > "enabled" : true,  
> > "path" : "post\_date",  
> > "type" : "date",  
> > "format" : "yyyy-MM-dd HH:mm:ss"  
> > }  
> > }  
> > }  
> > PUT tweet/tweet/1  
> > {  
> > "field1": "value",  
> > "post\_date": "2009-11-15 14:12:12"  
> > }  
> > PUT tweet/tweet/3  
> > {  
> > "field1": "value",  
> > "post\_date": "2009-09-15 14:12:12"  
> > }  
> > PUT tweet/tweet/2  
> > {  
> > "field1": "value",  
> > "post\_date": "2009-10-15 14:12:12"  
> > }  
> > PUT tweet/tweet/1  
> > {  
> > "field1": "value",  
> > "post\_date": "2009-11-15 14:12:12"  
> > }
> > 
> > Neither of these queries returns any documents : seems that any date with year 2009 is considered outside the range
> > 
> > GET tweet/\_search  
> > {  
> > "query": {  
> > "range": {  
> > "post\_date": {  
> > "from": "2009-01-01",  
> > "to": "2009-12-01"  
> > }  
> > }  
> > }  
> > }  
> > GET /tweet/\_search  
> > {  
> > "query" : {  
> > "filtered" : {  
> > "filter" : {  
> > "range" : {  
> > "post\_date" : {  
> > "gte" : "2009-01-01",  
> > "lt" : "2009-12-31"  
> > }  
> > }  
> > }  
> > }  
> > }  
> > }
> > 
> > > On Wednesday, April 30, 2014 2:28:16 PM UTC+1, Fatih Karatana wrote:  
> > > Hi guys,
> > > 
> > > I've been using Elasticsearch as my data store and I got lots of documents in it. My problem is, I figured it out that Elasticsearch does ignore month field regarding mapping and I can not get real search response.
> > > 
> > > Here is what I have in my index and my query, please tell me if I'm wrong:
> > > 
> > > curl -XPUT '[http://localhost:9200/tt6/](http://localhost:9200/tt6/)' -d '{}'  
> > > curl -XPUT '[http://localhost:9200/tt6/tweet/\_mapping](http://localhost:9200/tt6/tweet/_mapping)' -d '{"tweet" : {"properties" : {"date" : {"type" : "date", "format": "YYYY-MM-DD HH:mm:ss" }}}}'  
> > > curl -XPUT '[http://localhost:9200/tt6/tweet/1](http://localhost:9200/tt6/tweet/1)' -d '{"date": "2014-02-14 04:00:45"}'
> > > 
> > > curl -XGET '[http://localhost:9200/tt6/\_search](http://localhost:9200/tt6/_search)' -d '  
> > > {  
> > > "query": {  
> > > "bool": {  
> > > "must": [  
> > > {  
> > > "range": {  
> > > "tweet.date": {  
> > > "from": "2014-12-01 00:00:00",  
> > > "to": "2014-12-30 00:00:00"  
> > > }  
> > > }  
> > > }  
> > > ],  
> > > "must\_not": ,  
> > > "should":   
> > > }  
> > > },  
> > > "from": 0,  
> > > "size": 10,  
> > > "sort": ,  
> > > "facets": {}  
> > > }'
> > > 
> > > And my response is  
> > > {  
> > > "took": 3,  
> > > "timed\_out": false,  
> > > "\_shards": {  
> > > "total": 5,  
> > > "successful": 5,  
> > > "failed": 0  
> > > },  
> > > "hits": {  
> > > "total": 1,  
> > > "max\_score": 1,  
> > > "hits": [  
> > > {  
> > > "\_index": "tt6",  
> > > "\_type": "tweet",  
> > > "\_id": "1",  
> > > "\_score": 1,  
> > > "\_source": {  
> > > "date": "2014-02-14 04:00:45",  
> > > "name": "test"  
> > > }  
> > > }  
> > > ]  
> > > }  
> > > }
> > > 
> > > By given date range it must has no response beet 1st of December 2014 and 30th of December 2014, but it returns.
> > > 
> > > Any help will be appreciated.
> > > 
> > > Regards.
> > > 
> > > Fatih.  
> > > --  
> > > You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/9d494ca7-523e-467f-886a-0fe04e9e1223%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9d494ca7-523e-467f-886a-0fe04e9e1223%40googlegroups.com).  
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/a040b389-2516-46e3-9559-8968955f42d0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a040b389-2516-46e3-9559-8968955f42d0%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/39996F84-079B-4066-9A0C-A4AEC2D741B6%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/39996F84-079B-4066-9A0C-A4AEC2D741B6%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 1:10am UTC](https://discuss.elastic.co/t/date-range-query-ignore-month/17281/8 "2017-07-06T01:10:04Z")

</div>


