DLS: don't wrap twice

Original commit: elastic/x-pack-elasticsearch@86f6f7ac17
This commit is contained in:
Martijn van Groningen 2015-09-03 10:31:23 +02:00
parent fd962ea7dc
commit 1a84daab2a
1 changed files with 9 additions and 0 deletions

View File

@ -215,6 +215,15 @@ public final class ShieldIndexSearcherWrapper extends AbstractIndexShardComponen
}
private Query wrap(Query original) {
// If already wrapped, don't wrap twice:
if (original instanceof BooleanQuery) {
BooleanQuery bq = (BooleanQuery) original;
if (bq.clauses().size() == 2) {
if (roleQuery.equals(bq.clauses().get(1).getQuery())) {
return original;
}
}
}
BooleanQuery bq = new BooleanQuery();
bq.add(original, MUST);
bq.add(roleQuery, FILTER);