mirror of https://github.com/apache/lucene.git
LUCENE-6333: fix hashcode impl for TermsQuery
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1666528 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d4cba95df4
commit
fd86381062
|
@ -208,6 +208,11 @@ public class TermsQuery extends Query implements Accountable {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode() ^ this.hashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(String defaultField) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
|
|
@ -166,6 +166,15 @@ public class TermsQueryTest extends LuceneTestCase {
|
|||
assertFalse(right.equals(notEqual));
|
||||
}
|
||||
}
|
||||
|
||||
TermsQuery tq1 = new TermsQuery(new Term("thing", "apple"));
|
||||
TermsQuery tq2 = new TermsQuery(new Term("thing", "orange"));
|
||||
assertFalse(tq1.hashCode() == tq2.hashCode());
|
||||
|
||||
// different fields with the same term should have differing hashcodes
|
||||
tq1 = new TermsQuery(new Term("thing1", "apple"));
|
||||
tq2 = new TermsQuery(new Term("thing2", "apple"));
|
||||
assertFalse(tq1.hashCode() == tq2.hashCode());
|
||||
}
|
||||
|
||||
public void testSingleFieldEquals() {
|
||||
|
|
Loading…
Reference in New Issue