From 715d8b0ccf42d30661a7964c33bd27c9fec3d18e Mon Sep 17 00:00:00 2001 From: David Smiley Date: Tue, 23 May 2017 10:51:00 -0400 Subject: [PATCH] SOLR-10727: SolrIndexSearcher.numDocs empty docSet optimization --- solr/CHANGES.txt | 3 +++ .../src/java/org/apache/solr/search/SolrIndexSearcher.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 799df7459ce..7a604f4f45a 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -148,6 +148,9 @@ Optimizations string fields from the FieldCache, resulting in up to 56% better throughput for those cases. (yonik) +* SOLR-10727: Avoid polluting the filter cache for certain types of faceting (typically ranges) when + the base docset is empty. (David Smiley) + Other Changes ---------------------- * SOLR-10236: Removed FieldType.getNumericType(). Use getNumberType() instead. (Tomás Fernández Löbbe) diff --git a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java index 9d63aadeef3..599fd2461bc 100644 --- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java +++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java @@ -2033,6 +2033,9 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI * If there is a low-level I/O error. */ public int numDocs(Query a, DocSet b) throws IOException { + if (b.size() == 0) { + return 0; + } if (filterCache != null) { // Negative query if absolute value different from original Query absQ = QueryUtils.getAbs(a);