dls: compare the rewritten query

Original commit: elastic/x-pack-elasticsearch@b84d661f33
This commit is contained in:
Martijn van Groningen 2015-09-03 10:57:24 +02:00
parent 99d91b7a9c
commit f270e585f4
1 changed files with 4 additions and 6 deletions

View File

@ -6,10 +6,7 @@
package org.elasticsearch.shield.authz.accesscontrol;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.*;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.inject.Inject;
@ -212,12 +209,13 @@ public final class ShieldIndexSearcherWrapper extends AbstractIndexShardComponen
return "ShieldIndexSearcher(" + super.toString() + ")";
}
private Query wrap(Query original) {
private Query wrap(Query original) throws IOException {
// 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())) {
Query rewrittenRoleQuery = rewrite(roleQuery);
if (rewrittenRoleQuery.equals(bq.clauses().get(1).getQuery())) {
return original;
}
}