risdenk commented on code in PR #1183:
URL: https://github.com/apache/solr/pull/1183#discussion_r1025766090


##########
solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java:
##########
@@ -1211,17 +1211,42 @@ public ProcessedFilter getProcessedFilter(DocSet 
setFilter, List<Query> queries)
     }
 
     // Are all of our normal cached filters negative?
-    if (end > 0 && answer == null) {
-      answer = getLiveDocSet();
-    }
+    if (end > 0) {
+      if (answer == null) {
+        answer = getLiveDocSet();
+      }
 
-    // do negative queries first to shrink set size
-    for (int i = 0; i < end; i++) {
-      if (neg[i]) answer = answer.andNot(sets[i]);
-    }
+      // min size must be maxDoc based on BitDocSet conversion at the end
+      FixedBitSet tempAnswer = 
FixedBitSet.ensureCapacity(answer.getFixedBitSetClone(), maxDoc());
+
+      // do negative queries first to shrink set size
+      for (int i = 0; i < end; i++) {
+        if (neg[i]) {
+          // Clear any documents that are in the negative filter query
+          DocIterator iterator = sets[i].iterator();
+          while (iterator.hasNext()) {
+            int doc = iterator.nextDoc();
+            tempAnswer.clear(doc);
+          }
+        }
+      }
+
+      for (int i = 0; i < end; i++) {
+        if (!neg[i] && i != smallestIndex) {
+          DocIterator iterator = sets[i].iterator();

Review Comment:
   I need to add a comment around why not using `answer.intersection(sets[i])`



##########
solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java:
##########
@@ -1211,17 +1211,42 @@ public ProcessedFilter getProcessedFilter(DocSet 
setFilter, List<Query> queries)
     }
 
     // Are all of our normal cached filters negative?
-    if (end > 0 && answer == null) {
-      answer = getLiveDocSet();
-    }
+    if (end > 0) {
+      if (answer == null) {
+        answer = getLiveDocSet();
+      }
 
-    // do negative queries first to shrink set size
-    for (int i = 0; i < end; i++) {
-      if (neg[i]) answer = answer.andNot(sets[i]);
-    }
+      // min size must be maxDoc based on BitDocSet conversion at the end
+      FixedBitSet tempAnswer = 
FixedBitSet.ensureCapacity(answer.getFixedBitSetClone(), maxDoc());
+
+      // do negative queries first to shrink set size
+      for (int i = 0; i < end; i++) {
+        if (neg[i]) {
+          // Clear any documents that are in the negative filter query

Review Comment:
   I need to add a comment around why not using `answer.andNot(sets[i])`



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to