lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dsmi...@apache.org
Subject lucene-solr:master: SOLR-11595: optimize SolrIndexSearcher.collectionStatistics
Date Tue, 14 Nov 2017 21:58:56 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/master d77d54b1a -> 3923e9fba


SOLR-11595: optimize SolrIndexSearcher.collectionStatistics


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/3923e9fb
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/3923e9fb
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/3923e9fb

Branch: refs/heads/master
Commit: 3923e9fba3ebb9e6e0526dc4a511d4e33b366c90
Parents: d77d54b
Author: David Smiley <dsmiley@apache.org>
Authored: Tue Nov 14 16:58:49 2017 -0500
Committer: David Smiley <dsmiley@apache.org>
Committed: Tue Nov 14 16:58:49 2017 -0500

----------------------------------------------------------------------
 solr/CHANGES.txt                                          |  3 +++
 .../java/org/apache/solr/search/SolrIndexSearcher.java    | 10 +++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/3923e9fb/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index fe85f18..e603456 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -123,6 +123,9 @@ Optimizations
 * SOLR-11641: Change `frange` to default to `cost=100` so default behavior is to PostFilter
if user specifies
   `cache=false` (hossman)
 
+* SOLR-11595: SolrIndexSearcher.localCollectionStatistics is now faster by leveraging an
existing
+  cached MultiFields.  Noticeable when many fields are searched.  (David Smiley)
+
 Other Changes
 ----------------------
 * SOLR-11478: Solr should remove itself from live_nodes in zk immediately on shutdown. (Cao
Manh Dat)

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/3923e9fb/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
----------------------------------------------------------------------
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 6a178cb..0e8c022 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
@@ -367,7 +367,15 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable,
SolrI
   }
 
   public CollectionStatistics localCollectionStatistics(String field) throws IOException
{
-    return super.collectionStatistics(field);
+    // Could call super.collectionStatistics(field); but we can use a cached MultiTerms
+    assert field != null;
+    // SlowAtomicReader has a cache of MultiTerms
+    Terms terms = getSlowAtomicReader().terms(field);
+    if (terms == null) {
+      return null;
+    }
+    return new CollectionStatistics(field, reader.maxDoc(),
+        terms.getDocCount(), terms.getSumTotalTermFreq(), terms.getSumDocFreq());
   }
 
   public boolean isCachingEnabled() {


Mime
View raw message