Commit 99c5f7d5 by bergquist

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

parent 873024b9
......@@ -22,7 +22,6 @@ export class ElasticConfigCtrl {
];
esVersions = [
{name: '1.x', value: 1},
{name: '2.x', value: 2},
{name: '5.x', value: 5},
];
......
......@@ -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": {
......
......@@ -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});
}
};
......
......@@ -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'}],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment