Browse Source

feat(elastic): remove support for ES 1.x

bergquist 9 years ago
parent
commit
99c5f7d571

+ 0 - 1
public/app/plugins/datasource/elasticsearch/config_ctrl.ts

@@ -22,7 +22,6 @@ export class ElasticConfigCtrl {
   ];
 
   esVersions = [
-    {name: '1.x', value: 1},
     {name: '2.x', value: 2},
     {name: '5.x', value: 5},
   ];

+ 1 - 4
public/app/plugins/datasource/elasticsearch/datasource.js

@@ -81,12 +81,9 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes
       range[timeField]= {
         from: options.range.from.valueOf(),
         to: options.range.to.valueOf(),
+        format: "epoch_millis",
       };
 
-      if (this.esVersion >= 2) {
-        range[timeField]["format"] = "epoch_millis";
-      }
-
       var queryInterpolated = templateSrv.replace(queryString, {}, 'lucene');
       var query = {
         "bool": {

+ 8 - 12
public/app/plugins/datasource/elasticsearch/query_builder.js

@@ -11,11 +11,11 @@ function (queryDef) {
 
   ElasticQueryBuilder.prototype.getRangeFilter = function() {
     var filter = {};
-    filter[this.timeField] = {"gte": "$timeFrom", "lte": "$timeTo"};
-
-    if (this.esVersion >= 2) {
-      filter[this.timeField]["format"] = "epoch_millis";
-    }
+    filter[this.timeField] = {
+      gte: "$timeFrom",
+      lte: "$timeTo",
+      format: "epoch_millis",
+    };
 
     return filter;
   };
@@ -59,15 +59,12 @@ function (queryDef) {
     esAgg.field = this.timeField;
     esAgg.min_doc_count = settings.min_doc_count || 0;
     esAgg.extended_bounds = {min: "$timeFrom", max: "$timeTo"};
+    esAgg.format = "epoch_millis";
 
     if (esAgg.interval === 'auto') {
       esAgg.interval = "$interval";
     }
 
-    if (this.esVersion >= 2) {
-      esAgg.format = "epoch_millis";
-    }
-
     return esAgg;
   };
 
@@ -108,14 +105,13 @@ function (queryDef) {
       return;
     }
 
-    var i, filter, condition, must;
-    must = query.query.bool.must;
+    var i, filter, condition;
 
     for (i = 0; i < adhocFilters.length; i++) {
       filter = adhocFilters[i];
       condition = {};
       condition[filter.key] = filter.value;
-      must.push({"term": condition});
+      query.query.bool.must.push({"term": condition});
     }
   };
 

+ 0 - 33
public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts

@@ -50,39 +50,6 @@ describe('ElasticQueryBuilder', function() {
     expect(query.aggs["2"].aggs["3"].date_histogram.field).to.be("@timestamp");
   });
 
-  it('with es1.x and es2.x date histogram queries check time format', function() {
-    var builder_2x = new ElasticQueryBuilder({
-      timeField: '@timestamp',
-      esVersion: 2
-    });
-
-    var query_params = {
-      metrics: [],
-      bucketAggs: [
-        {type: 'date_histogram', field: '@timestamp', id: '1'}
-      ],
-    };
-
-    // format should not be specified in 1.x queries
-    expect("format" in builder.build(query_params)["aggs"]["1"]["date_histogram"]).to.be(false);
-
-    // 2.x query should specify format to be "epoch_millis"
-    expect(builder_2x.build(query_params)["aggs"]["1"]["date_histogram"]["format"]).to.be("epoch_millis");
-  });
-
-  it('with es1.x and es2.x range filter check time format', function() {
-    var builder_2x = new ElasticQueryBuilder({
-      timeField: '@timestamp',
-      esVersion: 2
-    });
-
-    // format should not be specified in 1.x queries
-    expect("format" in builder.getRangeFilter()["@timestamp"]).to.be(false);
-
-    // 2.x query should specify format to be "epoch_millis"
-    expect(builder_2x.getRangeFilter()["@timestamp"]["format"]).to.be("epoch_millis");
-  });
-
   it('with select field', function() {
     var query = builder.build({
       metrics: [{type: 'avg', field: '@value', id: '1'}],