You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ds...@apache.org on 2017/11/14 22:07:56 UTC
lucene-solr:branch_7x: SOLR-11595: optimize
SolrIndexSearcher.collectionStatistics
Repository: lucene-solr
Updated Branches:
refs/heads/branch_7x be154e9ea -> 0032ce48b
SOLR-11595: optimize SolrIndexSearcher.collectionStatistics
(cherry picked from commit 3923e9f)
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/0032ce48
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/0032ce48
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/0032ce48
Branch: refs/heads/branch_7x
Commit: 0032ce48b3886b226331aec06a5be4dfd4afffb8
Parents: be154e9
Author: David Smiley <ds...@apache.org>
Authored: Tue Nov 14 16:58:49 2017 -0500
Committer: David Smiley <ds...@apache.org>
Committed: Tue Nov 14 17:07:48 2017 -0500
----------------------------------------------------------------------
solr/CHANGES.txt | 3 +++
.../java/org/apache/solr/search/SolrIndexSearcher.java | 11 ++++++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/0032ce48/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 4250c29..b99bf28 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -107,6 +107,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/0032ce48/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..d11d2aa 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,16 @@ 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 new CollectionStatistics(field, reader.maxDoc(), 0, 0, 0);
+ } else {
+ return new CollectionStatistics(field, reader.maxDoc(),
+ terms.getDocCount(), terms.getSumTotalTermFreq(), terms.getSumDocFreq());
+ }
}
public boolean isCachingEnabled() {