# Problems with numericRangeFilter / date range query

**URL:** <https://discuss.elastic.co/t/problems-with-numericrangefilter-date-range-query/6600>\
**Category:** Elasticsearch\
**Created:** [February 6, 2012, 7:56am UTC](https://discuss.elastic.co/t/problems-with-numericrangefilter-date-range-query/6600 "2012-02-06T07:56:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andreas\_Fink](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andreas_fink/32/3002_2.png) [@Andreas\_Fink](https://discuss.elastic.co/u/Andreas_Fink)\
**Post date:** [February 6, 2012, 7:56am UTC](https://discuss.elastic.co/t/problems-with-numericrangefilter-date-range-query/6600/1 "2012-02-06T07:56:18Z")

</div>

Hi List.

I am trying to index a type (event) that contains a date.  
Then i want to find all events that lie between two dates.  
When querying via the java api, i get the following Exception

-- 8\< --

org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to execute phase [dfs], total failure; shardFailures {[1][gdp][0]: SearchParseException[[gdp][0]: query[ConstantScore(_:_)],from[0],size[60]: Parse Failure [Failed to parse source [🙂  
򃦲omsize$¸query򈭡tch\_all򻻅filter򌮵meric\_range򏥶ent\_start\_date򀉱1/02/2012toI12/02/2012include\_lower#include\_upper#󻻻]]]; nested: QueryParsingException[[gdp] Field [event\_start\_date] is not a numeric type]; }{[1][gdp][3]: SearchParseException[[gdp][3]: query[ConstantScore(_:_)],from[0],size[60]: Parse Failure [Failed to parse source [🙂  
򃦲omsize$¸query򈭡tch\_all򻻅filter򌮵meric\_range򏥶ent\_start\_date򀉱1/02/2012toI12/02/2012include\_lower#include\_upper#󻻻]]]; nested: QueryParsingException[[gdp] Field [event\_start\_date] is not a numeric type]; }{[1][gdp][2]: SearchParseException[[gdp][2]: query[ConstantScore(_:_)],from[0],size[60]: Parse Failure [Failed to parse source [🙂  
򃦲omsize$¸query򈭡tch\_all򻻅filter򌮵meric\_range򏥶ent\_start\_date򀉱1/02/2012toI12/02/2012include\_lower#include\_upper#󻻻]]]; nested: QueryParsingException[[gdp] Field [event\_start\_date] is not a numeric type]; }{[1][gdp][4]: SearchParseException[[gdp][4]: query[ConstantScore(_:_)],from[0],size[60]: Parse Failure [Failed to parse source [🙂  
򃦲omsize$¸query򈭡tch\_all򻻅filter򌮵meric\_range򏥶ent\_start\_date򀉱1/02/2012toI12/02/2012include\_lower#include\_upper#󻻻]]]; nested: QueryParsingException[[gdp] Field [event\_start\_date] is not a numeric type]; }{[1][gdp][1]: SearchParseException[[gdp][1]: query[ConstantScore(_:_)],from[0],size[60]: Parse Failure [Failed to parse source [🙂  
򃦲omsize$¸query򈭡tch\_all򻻅filter򌮵meric\_range򏥶ent\_start\_date򀉱1/02/2012toI12/02/2012include\_lower#include\_upper#󻻻]]]; nested: QueryParsingException[[gdp] Field [event\_start\_date] is not a numeric type]; }  
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.onFirstPhaseResult(TransportSearchTypeAction.java:258)  
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$3.onFailure(TransportSearchTypeAction.java:211)  
at org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteDfs(SearchServiceTransportAction.java:107)  
at org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchDfsQueryThenFetchAction.java:86)  
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:205)  
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:192)  
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$2.run(TransportSearchTypeAction.java:178)  
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)  
at java.lang.Thread.run(Thread.java:680)

-- 8\< --

Yes, the trace contains strange characters (Eclipse/Junit).  
I see that ES complains about the "event\_start\_date" not being numeric but from the docs it seems my mapping is alright.  
It is as following:

-- 8\< --

{  
event: {  
properties: {  
title\_id: {  
type: "long",  
index: "not\_analyzed"  
},  
event\_id: {  
type: "long",  
index: "not\_analyzed"  
},  
event\_start\_date: {  
type: "date",  
format: "dd/MM/yyyy"  
},  
event\_end\_date: {  
type: "date",  
format: "dd/MM/yyyy"  
},  
venue\_id: {  
type: "long",  
index: "not\_analyzed"  
}  
}  
}  
}

-- 8\< --

My query looks like this:

-- 8\< --

final SearchResponse res = \_client.prepareSearch(index)  
.setTypes(type)  
.setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH)  
.setQuery(QueryBuilders.matchAllQuery())  
.setFilter(FilterBuilders.numericRangeFilter(field)  
.gte("11/02/2012")  
.lte("13/02/2012")  
)  
.execute()  
.actionGet();

-- 8\< --

And a sample json of data:

-- 8\< --

{"title\_id":9000961601,"event\_id":10019937040,"event\_start\_date":"12/02/2012","event\_end\_date":"12/02/2012","venue\_id":9000961600}

-- 8\< --

Does anybody have an idea?  
I am new to Elasticsearch, just used Compass before. Please bear with me if this has been answered before but i couldn't find anything related online.

Thanks a lot,  
Andi.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [February 7, 2012, 10:36am UTC](https://discuss.elastic.co/t/problems-with-numericrangefilter-date-range-query/6600/2 "2012-02-07T10:36:21Z")

</div>

It seems like your mapping is correct, can you make sure that it has been applied properly by getting the mapping and validating? If you use curl, there is a specific get mapping endpoint: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-get-mapping.html). If you use Java, you use the cluster state API to get the mapping.

On Monday, February 6, 2012 at 9:56 AM, Andreas Fink wrote:

> Hi List.
> 
> I am trying to index a type (event) that contains a date.  
> Then i want to find all events that lie between two dates.  
> When querying via the java api, i get the following Exception
> 
> -- 8\< --
> 
> org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to execute phase [dfs], total failure; shardFailures {[1][gdp][0]: SearchParseException[[gdp][0]: query[ConstantScore(_:_)],from[0],size[60]: Parse Failure [Failed to parse source [🙂  
> 򃦲omsize$¸query򈭡tch\_all򻻅filter򌮵meric\_range򏥶ent\_start\_date򀉱1/02/2012toI12/02/2012include\_lower#include\_upper#󻻻]]]; nested: QueryParsingException[[gdp] Field [event\_start\_date] is not a numeric type]; }{[1][gdp][3]: SearchParseException[[gdp][3]: query[ConstantScore(_:_)],from[0],size[60]: Parse Failure [Failed to parse source [🙂  
> 򃦲omsize$¸query򈭡tch\_all򻻅filter򌮵meric\_range򏥶ent\_start\_date򀉱1/02/2012toI12/02/2012include\_lower#include\_upper#󻻻]]]; nested: QueryParsingException[[gdp] Field [event\_start\_date] is not a numeric type]; }{[1][gdp][2]: SearchParseException[[gdp][2]: query[ConstantScore(_:_)],from[0],size[60]: Parse Failure [Failed to parse source [🙂  
> 򃦲omsize$¸query򈭡tch\_all򻻅filter򌮵meric\_range򏥶ent\_start\_date򀉱1/02/2012toI12/02/2012include\_lower#include\_upper#󻻻]]]; nested: QueryParsingException[[gdp] Field [event\_start\_date] is not a numeric type]; }{[1][gdp][4]: SearchParseException[[gdp][4]: query[ConstantScore(_:_)],from[0],size[60]: Parse Failure [Failed to parse source [🙂  
> 򃦲omsize$¸query򈭡tch\_all򻻅filter򌮵meric\_range򏥶ent\_start\_date򀉱1/02/2012toI12/02/2012include\_lower#include\_upper#󻻻]]]; nested: QueryParsingException[[gdp] Field [event\_start\_date] is not a numeric type]; }{[1][gdp][1]: SearchParseException[[gdp][1]: query[ConstantScore(_:_)],from[0],size[60]: Parse Failure [Failed to parse source [🙂  
> 򃦲omsize$¸query򈭡tch\_all򻻅filter򌮵meric\_range򏥶ent\_start\_date򀉱1/02/2012toI12/02/2012include\_lower#include\_upper#󻻻]]]; nested: QueryParsingException[[gdp] Field [event\_start\_date] is not a numeric type]; }  
> at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.onFirstPhaseResult(TransportSearchTypeAction.java:258)  
> at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$3.onFailure(TransportSearchTypeAction.java:211)  
> at org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteDfs(SearchServiceTransportAction.java:107)  
> at org.elasticsearch.action.search.type.TransportSearchDfsQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchDfsQueryThenFetchAction.java:86)  
> at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:205)  
> at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:192)  
> at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$2.run(TransportSearchTypeAction.java:178)  
> at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)  
> at java.lang.Thread.run(Thread.java:680)
> 
> -- 8\< --
> 
> Yes, the trace contains strange characters (Eclipse/Junit).  
> I see that ES complains about the "event\_start\_date" not being numeric but from the docs it seems my mapping is alright.  
> It is as following:
> 
> -- 8\< --
> 
> {  
> event: {  
> properties: {  
> title\_id: {  
> type: "long",  
> index: "not\_analyzed"  
> },  
> event\_id: {  
> type: "long",  
> index: "not\_analyzed"  
> },  
> event\_start\_date: {  
> type: "date",  
> format: "dd/MM/yyyy"  
> },  
> event\_end\_date: {  
> type: "date",  
> format: "dd/MM/yyyy"  
> },  
> venue\_id: {  
> type: "long",  
> index: "not\_analyzed"  
> }  
> }  
> }  
> }
> 
> -- 8\< --
> 
> My query looks like this:
> 
> -- 8\< --
> 
> final SearchResponse res = \_client.prepareSearch(index)  
> .setTypes(type)  
> .setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH)  
> .setQuery(QueryBuilders.matchAllQuery())  
> .setFilter(FilterBuilders.numericRangeFilter(field)  
> .gte("11/02/2012")  
> .lte("13/02/2012")  
> )  
> .execute()  
> .actionGet();
> 
> -- 8\< --
> 
> And a sample json of data:
> 
> -- 8\< --
> 
> {"title\_id":9000961601,"event\_id":10019937040,"event\_start\_date":"12/02/2012","event\_end\_date":"12/02/2012","venue\_id":9000961600}
> 
> -- 8\< --
> 
> Does anybody have an idea?  
> I am new to Elasticsearch, just used Compass before. Please bear with me if this has been answered before but i couldn't find anything related online.
> 
> Thanks a lot,  
> Andi.

---

<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, 3:40am UTC](https://discuss.elastic.co/t/problems-with-numericrangefilter-date-range-query/6600/3 "2017-07-06T03:40:17Z")

</div>


