Properly cache parent/child queries in the case they are wrapped in a compound filter.
Closes #2971
This commit is contained in:
parent
f430953ca1
commit
59a741cee5
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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(')');
|
||||
|
|
Loading…
Reference in New Issue