Apache Lucene open-source search software
SOLR-11769: optimize useFilterForSortedQuery=true when no filter queries
David Smileyef989124f345
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 3a297e00eca..6ddb6b3b10c 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -239,6 +239,9 @@ Optimizations* SOLR-8327: Cluster state caching to avoid live fetch from ZK of cluster state for forwarding requests on nodesthat do not host any replica of the collection (Jessica Cheng Mallet, John Gallagher, Noble Paul, Ishan Chattopadhyaya)+* SOLR-11769: Optimize when useFilterForSortedQuery=true and there are no filter queries by avoiding+ needless match-all-docs bitset construction. (Betim Deva, David Smiley)+Other Changes----------------------diff --git a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.javaindex 34374764807..8dadd37c1fe 100644--- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java+++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java@@ -1397,8 +1397,10 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI// slower than simply re-executing the query.if (out.docSet == null) {out.docSet = getDocSet(cmd.getQuery(), cmd.getFilter());- DocSet bigFilt = getDocSet(cmd.getFilterList());- if (bigFilt != null) out.docSet = out.docSet.intersection(bigFilt);+ List<Query> filterList = cmd.getFilterList();+ if (filterList != null && !filterList.isEmpty()) {+ out.docSet = out.docSet.intersection(getDocSet(cmd.getFilterList()));+ }}// todo: there could be a sortDocSet that could take a list of// the filters instead of anding them first...