Skip to content

Commit

Permalink
fix(tsvb-server): Ignore query bar search on ignore_global_filters param
Browse files Browse the repository at this point in the history
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
  • Loading branch information
markov00 committed Jan 23, 2019
1 parent 5e78ee9 commit 9384a2d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,35 @@ export default function query(req, panel, annotation, esQueryConfig, indexPatter
const { from, to } = getTimerange(req);

doc.size = 0;
const queries = req.payload.query || [];
const queries = !annotation.ignore_global_filters ? req.payload.query : [];
const filters = !annotation.ignore_global_filters ? req.payload.filters : [];
doc.query = buildEsQuery(indexPattern, queries, filters, esQueryConfig);
const timerange = {
range: {
[timeField]: {
gte: from.valueOf(),
lte: to.valueOf() - (bucketSize * 1000),
lte: to.valueOf() - bucketSize * 1000,
format: 'epoch_millis',
}
}
},
},
};
doc.query.bool.must.push(timerange);

if (annotation.query_string) {
doc.query.bool.must.push({
query_string: {
query: annotation.query_string,
analyze_wildcard: true
}
analyze_wildcard: true,
},
});
}

if (!annotation.ignore_panel_filters && panel.filter) {
doc.query.bool.must.push({
query_string: {
query: panel.filter,
analyze_wildcard: true
}
analyze_wildcard: true,
},
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function query(req, panel, series, esQueryConfig, indexPattern) {
const { from, to } = offsetTime(req, series.offset_time);

doc.size = 0;
const queries = req.payload.query || [];
const queries = !panel.ignore_global_filter ? req.payload.query : [];
const filters = !panel.ignore_global_filter ? req.payload.filters : [];
doc.query = buildEsQuery(indexPattern, queries, filters, esQueryConfig);

Expand All @@ -37,30 +37,29 @@ export default function query(req, panel, series, esQueryConfig, indexPattern) {
gte: from.valueOf(),
lte: to.valueOf(),
format: 'epoch_millis',
}
}
},
},
};
doc.query.bool.must.push(timerange);

if (panel.filter) {
doc.query.bool.must.push({
query_string: {
query: panel.filter,
analyze_wildcard: true
}
analyze_wildcard: true,
},
});
}

if (series.filter) {
doc.query.bool.must.push({
query_string: {
query: series.filter,
analyze_wildcard: true
}
analyze_wildcard: true,
},
});
}

return next(doc);

};
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,30 @@ export default function query(req, panel, esQueryConfig, indexPattern) {

doc.size = 0;

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


const timerange = {
range: {
[timeField]: {
gte: from.valueOf(),
lte: to.valueOf(),
format: 'epoch_millis',
}
}
},
},
};
doc.query.bool.must.push(timerange);

if (panel.filter) {
doc.query.bool.must.push({
query_string: {
query: panel.filter,
analyze_wildcard: true
}
analyze_wildcard: true,
},
});
}

return next(doc);

};
}

0 comments on commit 9384a2d

Please sign in to comment.