diff --git a/src/main/java/org/elasticsearch/index/search/child/ChildrenQuery.java b/src/main/java/org/elasticsearch/index/search/child/ChildrenQuery.java index 0be6e2de558..dd69a642a05 100644 --- a/src/main/java/org/elasticsearch/index/search/child/ChildrenQuery.java +++ b/src/main/java/org/elasticsearch/index/search/child/ChildrenQuery.java @@ -83,6 +83,36 @@ public class ChildrenQuery extends Query implements SearchContext.Rewrite { this.uidToCount = unProcessedQuery.uidToCount; } + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || obj.getClass() != this.getClass()) { + return false; + } + + HasChildFilter that = (HasChildFilter) obj; + if (!originalChildQuery.equals(that.childQuery)) { + return false; + } + if (!childType.equals(that.childType)) { + return false; + } + if (!parentType.equals(that.parentType)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int result = originalChildQuery.hashCode(); + result = 31 * result + parentType.hashCode(); + result = 31 * result + childType.hashCode(); + return result; + } + @Override public String toString(String field) { StringBuilder sb = new StringBuilder(); diff --git a/src/main/java/org/elasticsearch/index/search/child/ParentQuery.java b/src/main/java/org/elasticsearch/index/search/child/ParentQuery.java index f1eb3b3b364..dee0aed2584 100644 --- a/src/main/java/org/elasticsearch/index/search/child/ParentQuery.java +++ b/src/main/java/org/elasticsearch/index/search/child/ParentQuery.java @@ -96,6 +96,32 @@ public class ParentQuery extends Query implements SearchContext.Rewrite { uidToScore = null; } + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || obj.getClass() != this.getClass()) { + return false; + } + + HasParentFilter that = (HasParentFilter) obj; + if (!originalParentQuery.equals(that.parentQuery)) { + return false; + } + if (!parentType.equals(that.parentType)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int result = originalParentQuery.hashCode(); + result = 31 * result + parentType.hashCode(); + return result; + } + @Override public String toString(String field) { StringBuilder sb = new StringBuilder(); diff --git a/src/main/java/org/elasticsearch/index/search/child/TopChildrenQuery.java b/src/main/java/org/elasticsearch/index/search/child/TopChildrenQuery.java index 0cac628e06a..5732e987523 100644 --- a/src/main/java/org/elasticsearch/index/search/child/TopChildrenQuery.java +++ b/src/main/java/org/elasticsearch/index/search/child/TopChildrenQuery.java @@ -252,6 +252,36 @@ public class TopChildrenQuery extends Query implements SearchContext.Rewrite { return new ParentWeight(searcher, rewrittenChildQuery.createWeight(searcher)); } + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || obj.getClass() != this.getClass()) { + return false; + } + + HasChildFilter that = (HasChildFilter) obj; + if (!originalChildQuery.equals(that.childQuery)) { + return false; + } + if (!childType.equals(that.childType)) { + return false; + } + if (!parentType.equals(that.parentType)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int result = originalChildQuery.hashCode(); + result = 31 * result + parentType.hashCode(); + result = 31 * result + childType.hashCode(); + return result; + } + public String toString(String field) { StringBuilder sb = new StringBuilder(); sb.append("score_child[").append(childType).append("/").append(parentType).append("](").append(originalChildQuery.toString(field)).append(')');