Skip to content

Commit 9384a2d

Browse files
committed
fix(tsvb-server): Ignore query bar search on ignore_global_filters param
This commit mimic the behaviour of the ignore_global_filters currently used with lucene syntax: if you enable the ignore_global_filter option on data or on annotations, data or annotations are filtered out when using the filter bar and the search bar
1 parent 5e78ee9 commit 9384a2d

3 files changed

Lines changed: 20 additions & 23 deletions

File tree

src/legacy/core_plugins/metrics/server/lib/vis_data/request_processors/annotations/query.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,35 +28,35 @@ export default function query(req, panel, annotation, esQueryConfig, indexPatter
2828
const { from, to } = getTimerange(req);
2929

3030
doc.size = 0;
31-
const queries = req.payload.query || [];
31+
const queries = !annotation.ignore_global_filters ? req.payload.query : [];
3232
const filters = !annotation.ignore_global_filters ? req.payload.filters : [];
3333
doc.query = buildEsQuery(indexPattern, queries, filters, esQueryConfig);
3434
const timerange = {
3535
range: {
3636
[timeField]: {
3737
gte: from.valueOf(),
38-
lte: to.valueOf() - (bucketSize * 1000),
38+
lte: to.valueOf() - bucketSize * 1000,
3939
format: 'epoch_millis',
40-
}
41-
}
40+
},
41+
},
4242
};
4343
doc.query.bool.must.push(timerange);
4444

4545
if (annotation.query_string) {
4646
doc.query.bool.must.push({
4747
query_string: {
4848
query: annotation.query_string,
49-
analyze_wildcard: true
50-
}
49+
analyze_wildcard: true,
50+
},
5151
});
5252
}
5353

5454
if (!annotation.ignore_panel_filters && panel.filter) {
5555
doc.query.bool.must.push({
5656
query_string: {
5757
query: panel.filter,
58-
analyze_wildcard: true
59-
}
58+
analyze_wildcard: true,
59+
},
6060
});
6161
}
6262

src/legacy/core_plugins/metrics/server/lib/vis_data/request_processors/series/query.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default function query(req, panel, series, esQueryConfig, indexPattern) {
2727
const { from, to } = offsetTime(req, series.offset_time);
2828

2929
doc.size = 0;
30-
const queries = req.payload.query || [];
30+
const queries = !panel.ignore_global_filter ? req.payload.query : [];
3131
const filters = !panel.ignore_global_filter ? req.payload.filters : [];
3232
doc.query = buildEsQuery(indexPattern, queries, filters, esQueryConfig);
3333

@@ -37,30 +37,29 @@ export default function query(req, panel, series, esQueryConfig, indexPattern) {
3737
gte: from.valueOf(),
3838
lte: to.valueOf(),
3939
format: 'epoch_millis',
40-
}
41-
}
40+
},
41+
},
4242
};
4343
doc.query.bool.must.push(timerange);
4444

4545
if (panel.filter) {
4646
doc.query.bool.must.push({
4747
query_string: {
4848
query: panel.filter,
49-
analyze_wildcard: true
50-
}
49+
analyze_wildcard: true,
50+
},
5151
});
5252
}
5353

5454
if (series.filter) {
5555
doc.query.bool.must.push({
5656
query_string: {
5757
query: series.filter,
58-
analyze_wildcard: true
59-
}
58+
analyze_wildcard: true,
59+
},
6060
});
6161
}
6262

6363
return next(doc);
64-
6564
};
6665
}

src/legacy/core_plugins/metrics/server/lib/vis_data/request_processors/table/query.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,30 @@ export default function query(req, panel, esQueryConfig, indexPattern) {
2727

2828
doc.size = 0;
2929

30-
const queries = req.payload.query || [];
30+
const queries = !panel.ignore_global_filter ? req.payload.query : [];
3131
const filters = !panel.ignore_global_filter ? req.payload.filters : [];
3232
doc.query = buildEsQuery(indexPattern, queries, filters, esQueryConfig);
3333

34-
3534
const timerange = {
3635
range: {
3736
[timeField]: {
3837
gte: from.valueOf(),
3938
lte: to.valueOf(),
4039
format: 'epoch_millis',
41-
}
42-
}
40+
},
41+
},
4342
};
4443
doc.query.bool.must.push(timerange);
4544

4645
if (panel.filter) {
4746
doc.query.bool.must.push({
4847
query_string: {
4948
query: panel.filter,
50-
analyze_wildcard: true
51-
}
49+
analyze_wildcard: true,
50+
},
5251
});
5352
}
5453

5554
return next(doc);
56-
5755
};
5856
}

0 commit comments

Comments
 (0)