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.