LUCENE-2092: fix BooleanQuery.equals/hashCode to pay attention to disableCoord

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@883554 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2009-11-24 00:04:20 +00:00
parent e69141c51a
commit fb9087fa33
4 changed files with 9 additions and 4 deletions

View File

@ -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

View File

@ -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}"/>

View File

@ -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.*/
@Override
public int hashCode() {
return Float.floatToIntBits(getBoost()) ^ clauses.hashCode()
+ getMinimumNumberShouldMatch();
+ getMinimumNumberShouldMatch() + (disableCoord ? 17:0);
}
}

View File

@ -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));
}