diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/util/lucene/search/Queries.java b/modules/elasticsearch/src/main/java/org/elasticsearch/util/lucene/search/Queries.java index 6a9cd09a21b..d44d1b31aa8 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/util/lucene/search/Queries.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/util/lucene/search/Queries.java @@ -54,31 +54,9 @@ public class Queries { * Optimizes the given query and returns the optimized version of it. */ public static Query optimizeQuery(Query q) { - if (q instanceof BooleanQuery) { - return optimizeBooleanQuery((BooleanQuery) q); - } return q; } - public static BooleanQuery optimizeBooleanQuery(BooleanQuery q) { - BooleanQuery optimized = new BooleanQuery(q.isCoordDisabled()); - optimized.setMinimumNumberShouldMatch(q.getMinimumNumberShouldMatch()); - optimizeBooleanQuery(optimized, q); - return optimized; - } - - public static void optimizeBooleanQuery(BooleanQuery optimized, BooleanQuery q) { - for (BooleanClause clause : q.clauses()) { - Query cq = clause.getQuery(); - cq.setBoost(cq.getBoost() * q.getBoost()); - if (cq instanceof BooleanQuery && !clause.isRequired() && !clause.isProhibited()) { - optimizeBooleanQuery(optimized, (BooleanQuery) cq); - } else { - optimized.add(clause); - } - } - } - public static boolean isNegativeQuery(Query q) { if (!(q instanceof BooleanQuery)) { return false;