Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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"
}
}
}
]
}
}
}
}
}
}
}
Posted
Updated 27-Apr-16 19:26pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900