diff --git a/CHANGES.txt b/CHANGES.txt index d33e347e7e2..c1a68817c3c 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -13,6 +13,10 @@ API Changes Bug fixes +* LUCENE-2092: BooleanQuery was ignoring disableCoord in its hashCode + and equals methods, cause bad things to happen when caching + BooleanQueries. (Chris Hostetter, Mike McCandless) + New features Optimizations diff --git a/common-build.xml b/common-build.xml index b40352a299a..c26476045e0 100644 --- a/common-build.xml +++ b/common-build.xml @@ -42,7 +42,7 @@ - + diff --git a/src/java/org/apache/lucene/search/BooleanQuery.java b/src/java/org/apache/lucene/search/BooleanQuery.java index 7abc57c5154..a11f7aef40e 100644 --- a/src/java/org/apache/lucene/search/BooleanQuery.java +++ b/src/java/org/apache/lucene/search/BooleanQuery.java @@ -469,14 +469,15 @@ public class BooleanQuery extends Query implements Iterable { BooleanQuery other = (BooleanQuery)o; return (this.getBoost() == other.getBoost()) && this.clauses.equals(other.clauses) - && this.getMinimumNumberShouldMatch() == other.getMinimumNumberShouldMatch(); + && this.getMinimumNumberShouldMatch() == other.getMinimumNumberShouldMatch() + && this.disableCoord == other.disableCoord; } /** Returns a hash code value for this object.*/ @Override public int hashCode() { return Float.floatToIntBits(getBoost()) ^ clauses.hashCode() - + getMinimumNumberShouldMatch(); + + getMinimumNumberShouldMatch() + (disableCoord ? 17:0); } } diff --git a/src/test/org/apache/lucene/search/TestWildcard.java b/src/test/org/apache/lucene/search/TestWildcard.java index 810bedcf27f..19ea2a5b8c9 100644 --- a/src/test/org/apache/lucene/search/TestWildcard.java +++ b/src/test/org/apache/lucene/search/TestWildcard.java @@ -104,7 +104,7 @@ public class TestWildcard MultiTermQuery wq = new WildcardQuery(new Term("field", "")); wq.setRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE); assertMatches(searcher, wq, 0); - BooleanQuery expected = new BooleanQuery(); + BooleanQuery expected = new BooleanQuery(true); assertEquals(searcher.rewrite(expected), searcher.rewrite(wq)); }