fix(elasticsearch): refactoring of #3321

This commit is contained in:
Torkel Ödegaard
2015-12-03 18:30:36 +01:00
parent f1cb8f2f25
commit db9c288050
5 changed files with 11 additions and 14 deletions

View File

@@ -5,15 +5,14 @@ function () {
function ElasticQueryBuilder(options) {
this.timeField = options.timeField;
this.elasticsearchVersion = options.elasticsearchVersion;
this.esVersion = options.esVersion;
}
ElasticQueryBuilder.prototype.getRangeFilter = function() {
var filter = {};
filter[this.timeField] = {"gte": "$timeFrom", "lte": "$timeTo"};
// elastic search versions 2.x require the time format to be specified
if (this.elasticsearchVersion >= 2) {
if (this.esVersion >= 2) {
filter[this.timeField]["format"] = "epoch_millis";
}
@@ -137,8 +136,7 @@ function () {
"min_doc_count": 0,
"extended_bounds": { "min": "$timeFrom", "max": "$timeTo" }
};
// elastic search versions 2.x require the time format to be specified
if (this.elasticsearchVersion >= 2) {
if (this.esVersion >= 2) {
esAgg["date_histogram"]["format"] = "epoch_millis";
}
break;