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.
I need help if anyone can that would be appreciated
What I have tried:
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"
}
}
}
]
}
}
}
}
}
}
}