Dealing with an issue with Date Range filter

I am working on Elastic Search and trying to fetch data by using aggregation queries from angularjs UI pages, we are using Elasticseach.js, Elastic.js etc plugins for

posting the request and getting the response, everything is working here for me except Date Range filters means Range filters is not working.
Below is my query which i am using for posting a request:-

var filters = [ejs.RangeFilter('purchaseDate').gte(this.startDate).lte(this.endDate)];
var composedFilter = ejs.AndFilter(filters);
var myQuery = ejs.TermsAggregation('parentsku')
.field(skufield.value)
.order("_term", "asc")
.size(0)
.agg(ejs.StatsAggregation('cost').field('directCost'))
.agg(ejs.StatsAggregation('sales').field('revenu'))
.agg(ejs.StatsAggregation('salesQuantity').field('salesQuantity'))
.agg(ejs.StatsAggregation('quantity').field('quantity'))
.agg(ejs.FilterAggregation('filtered').filter(composedFilter));

Here "purchaseDate" is the field in Elastic search Index on which i am trying to apply range filter.

Its json form of this is:-

{
"aggs":{
"parentsku":{
"terms":{
"field":"parentSku",
"order":{
"_term":"asc"
},
"size":0
},
"aggs":{
"cost":{
"stats":{
"field":"directCost"
}
},
"sales":{
"stats":{
"field":"revenu"
}
},
"salesQuantity":{
"stats":{
"field":"salesQuantity"
}
},
"quantity":{
"stats":{
"field":"quantity"
}
},
"filtered":{
"filter":{
"and":{
"filters":[
{
"range":{
"purchaseDate":{
"gte":"2016-03-01",
"lte":"2016-04-10"
}
}
}
]
}
}
}
}
}
}
}

I need help if anyone can that would be appreciated.

Try the following filter:

{
	"filtered": {
		"filter": {
			"range": {
				"purchaseDate": {
					"gte": "2016-03-01",
					"lte": "2016-04-10"
				}
			}
		}
	}
}

Good luck! :slight_smile:

Thanks Gui,
I tried this it works but i need to select more values with a specific format that is because i am using aggregation kind of things...
var filters = [ejs.RangeFilter('purchaseDate').gte(this.startDate).lte(this.endDate)];
var composedFilter = ejs.AndFilter(filters);
var myQuery = ejs.TermsAggregation('parentsku')
.field(skufield.value)
.order("_term", "asc")
.size(0)
.agg(ejs.StatsAggregation('cost').field('directCost'))
.agg(ejs.StatsAggregation('sales').field('revenu'))
.agg(ejs.StatsAggregation('salesQuantity').field('salesQuantity'))
.agg(ejs.StatsAggregation('quantity').field('quantity'))
.agg(ejs.FilterAggregation('filtered').filter(composedFilter));

I think i am misplacing filter here it is not the problem of Date range although i am facing same issue with every attribute like Quantity, cost etc.
Can you please help on that??