Apache Solr open-source search software
LUCENE-2092: fix BooleanQuery.equals/hashCode to pay attention to disableCoord
Michael McCandlessfb9087fa33bd
diff --git a/CHANGES.txt b/CHANGES.txtindex d33e347e7e2..c1a68817c3c 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -13,6 +13,10 @@ API ChangesBug 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 featuresOptimizationsdiff --git a/common-build.xml b/common-build.xmlindex b40352a299a..c26476045e0 100644--- a/common-build.xml+++ b/common-build.xml@@ -42,7 +42,7 @@<property name="Name" value="Lucene"/><property name="dev.version" value="3.1-dev"/><property name="version" value="${dev.version}"/>- <property name="compatibility.tag" value="lucene_3_0_back_compat_tests_20091116"/>+ <property name="compatibility.tag" value="lucene_3_0_back_compat_tests_20091123"/><property name="spec.version" value="${version}"/><property name="year" value="2000-${current.year}"/><property name="final.name" value="lucene-${name}-${version}"/>diff --git a/src/java/org/apache/lucene/search/BooleanQuery.java b/src/java/org/apache/lucene/search/BooleanQuery.javaindex 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<BooleanClause> {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.*/@Overridepublic 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.javaindex 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 TestWildcardMultiTermQuery 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));}