nfsantos commented on code in PR #1149: URL: https://github.com/apache/jackrabbit-oak/pull/1149#discussion_r1363734389
########## oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexStatistics.java: ########## @@ -251,26 +264,33 @@ static class StatsRequestDescriptor { final String index; @Nullable final String field; + @Nullable + final Query query; StatsRequestDescriptor(@NotNull ElasticConnection connection, @NotNull String index) { - this(connection, index, null); + this(connection, index, null, null); } StatsRequestDescriptor(@NotNull ElasticConnection connection, - @NotNull String index, @Nullable String field) { + @NotNull String index, @Nullable String field, @Nullable Query query) { this.connection = connection; this.index = index; this.field = field; + this.query = query; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; StatsRequestDescriptor that = (StatsRequestDescriptor) o; + String thisInternalQuery = query != null ? query.toString() : null; + String thatInternalQuery = that.query != null ? that.query.toString() : null; return index.equals(that.index) && - Objects.equals(field, that.field); + Objects.equals(field, that.field) && + // ES Query objects are not comparable, so we need to compare their string representations + Objects.equals(thisInternalQuery, thatInternalQuery); } Review Comment: Maybe you should also update hashCode to consider the query string. I think having hashCode consider only a subset of fields from equals does not violate the contract for hashCode, but might not be optimal as it will increase the chance of collisions (two different objects with the same values in index and field will have the same hash code). -- 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: dev-unsubscr...@jackrabbit.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org