Apache Solr open-source search software
queryResultMaxDocsCached: SOLR-291
Yonik Seeley0d8a368a97f8
diff --git a/CHANGES.txt b/CHANGES.txtindex 074848a86f9..0e285a594eb 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -95,6 +95,10 @@ New Features15. SOLR-273: Added hl.maxAnalyzedChars highlighting parameter, defaulting to50k (klaas)+16. SOLR-291: Control maximum number of documents to cache for any entry+ in the queryResultCache via queryResultMaxDocsCached solrconfig.xml+ entry. (Koji Sekiguchi via yonik)+Changes in runtime behaviorOptimizationsdiff --git a/example/solr/conf/solrconfig.xml b/example/solr/conf/solrconfig.xmlindex c0a1ca08361..54ad03d26b6 100755--- a/example/solr/conf/solrconfig.xml+++ b/example/solr/conf/solrconfig.xml@@ -180,9 +180,13 @@is requested, a superset of the requested number of document idsare collected. For example, if a search for a particular queryrequests matching documents 10 through 19, and queryWindowSize is 50,- then documents 0 through 50 will be collected and cached. Any further+ then documents 0 through 49 will be collected and cached. Any furtherrequests in that range can be satisfied via the cache. -->- <queryResultWindowSize>10</queryResultWindowSize>+ <queryResultWindowSize>50</queryResultWindowSize>++ <!-- Maximum number of documents to cache for any entry in the+ queryResultCache. -->+ <queryResultMaxDocsCached>200</queryResultMaxDocsCached><!-- This entry enables an int hash representation for filters (DocSets)when the number of items in the set is less than maxSize. For smallerdiff --git a/src/java/org/apache/solr/search/SolrIndexSearcher.java b/src/java/org/apache/solr/search/SolrIndexSearcher.javaindex 236db9fcd55..c076929b9ce 100644--- a/src/java/org/apache/solr/search/SolrIndexSearcher.java+++ b/src/java/org/apache/solr/search/SolrIndexSearcher.java@@ -259,6 +259,7 @@ public class SolrIndexSearcher extends Searcher implements SolrInfoMBean {private static boolean useFilterForSortedQuery=SolrConfig.config.getBool("query/useFilterForSortedQuery", false);private static int queryResultWindowSize=SolrConfig.config.getInt("query/queryResultWindowSize", 1);+ private static int queryResultMaxDocsCached=SolrConfig.config.getInt("query/queryResultMaxDocsCached", Integer.MAX_VALUE);public Hits search(Query query, Filter filter, Sort sort) throws IOException {@@ -808,8 +809,9 @@ public class SolrIndexSearcher extends Searcher implements SolrInfoMBean {out.docList = superset.subset(offset,len);}- // lastly, put the superset in the cache- if (key != null) {+ // lastly, put the superset in the cache if the size is less than or equal+ // to queryResultMaxDocsCached+ if (key != null && superset.size() <= queryResultMaxDocsCached) {queryResultCache.put(key, superset);}}