Skip to content

Apache Lucene open-source search software

SOLR-5624: check for elevated documents in hashCode()

Joel Bernstein9e2995ee0124
diff --git a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
index 84934842cd8..eb36fab32c1 100644
--- a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
@@ -153,6 +153,20 @@ public class CollapsingQParserPlugin extends QParserPlugin {
}
public int hashCode() {
+
+ /*
+ * Checking for boosted here because the request context will not have the elevated docs
+ * until after the query is constructed. So to be sure there are no elevated docs in the query
+ * while checking the cache we must check the request context during the call to hashCode().
+ */
+
+ if(this.boosted == null) {
+ SolrRequestInfo info = SolrRequestInfo.getRequestInfo();
+ if(info != null) {
+ this.boosted = (Set<String>)info.getReq().getContext().get(QueryElevationComponent.BOOSTED);
+ }
+ }
+
int hashCode = field.hashCode();
hashCode = max!=null ? hashCode+max.hashCode():hashCode;
hashCode = min!=null ? hashCode+min.hashCode():hashCode;