From b49864299deada6cf2a8d3483a1852eb83ef718c Mon Sep 17 00:00:00 2001 From: kimchy Date: Fri, 14 May 2010 08:16:10 +0300 Subject: [PATCH] fix wrong optimization on boolean query --- .../util/lucene/search/Queries.java | 22 ------------------- 1 file changed, 22 deletions(-) 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;