rafalh commented on code in PR #12354:
URL: https://github.com/apache/lucene/pull/12354#discussion_r2534209126


##########
lucene/core/src/java/org/apache/lucene/search/TermQuery.java:
##########
@@ -264,11 +264,25 @@ public TermStates getTermStates() {
   /** Returns true iff <code>other</code> is equal to <code>this</code>. */
   @Override
   public boolean equals(Object other) {
-    return sameClassAs(other) && term.equals(((TermQuery) other).term);
+    if (!sameClassAs(other)) {
+      return false;
+    }
+    TermQuery otherTermQuery = (TermQuery) other;
+    if (!term.equals(otherTermQuery.term)) {
+      return false;
+    }
+    if (perReaderTermState != null && otherTermQuery.perReaderTermState != 
null) {
+      return perReaderTermState.docFreq() == 
otherTermQuery.perReaderTermState.docFreq();

Review Comment:
   Done. I didn't do it in the first place because `TermStates` has more fields 
so it felt wrong to implement `equals`/`hashCode` based only on one field, but 
at the same time I wasn't sure what is the meaning of other fields and I was 
worried that comparing them too would affect performance. Let me know if new 
code is okay for you or if I should make some adjustments



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to