dsmiley commented on a change in pull request #780: SOLR-11866: Support 
efficient subset matching in query elevation rules
URL: https://github.com/apache/lucene-solr/pull/780#discussion_r303658212
 
 

 ##########
 File path: 
solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
 ##########
 @@ -1020,8 +1066,58 @@ public Elevation(Set<BytesRef> elevatedIds, 
Set<BytesRef> excludedIds,
         for (BytesRef excludedId : excludedIds) {
           excludeQueriesBuilder.add(new TermQuery(new Term(queryFieldName, 
excludedId)));
         }
-        excludeQueries = excludeQueriesBuilder.toArray(new 
TermQuery[excludeQueriesBuilder.size()]);
+        excludeQueries = excludeQueriesBuilder.toArray(new TermQuery[0]);
+      }
+    }
+
+    protected Elevation(Set<BytesRef> elevatedIds, BooleanQuery includeQuery, 
Set<BytesRef> excludedIds, TermQuery[] excludeQueries) {
+      this.elevatedIds = elevatedIds;
+      this.includeQuery = includeQuery;
+      this.excludedIds = excludedIds;
+      this.excludeQueries = excludeQueries;
+    }
+
+    /**
+     * Merges this {@link Elevation} with another and creates a new {@link 
Elevation}.
+
+     * @return A new instance containing the merging of the two elevations; or 
directly this elevation if the other
+     *         is <code>null</code>.
+     */
+    protected Elevation mergeWith(Elevation elevation) {
+      if (elevation == null) {
+        return this;
+      }
+      Set<BytesRef> elevatedIds = 
ImmutableSet.<BytesRef>builder().addAll(this.elevatedIds).addAll(elevation.elevatedIds).build();
+      boolean overlappingElevatedIds = elevatedIds.size() != 
(this.elevatedIds.size() + elevation.elevatedIds.size());
+      BooleanQuery.Builder includeQueryBuilder = new BooleanQuery.Builder();
+      Set<BooleanClause> clauseSet = (overlappingElevatedIds ? new HashSet<>() 
: null);
 
 Review comment:
   initialize the HashSet with elevatedIds.size()

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to