queryResultMaxDocsCached: SOLR-291

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@554688 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2007-07-09 15:45:30 +00:00
parent b51e9a42f7
commit 0d8a368a97
3 changed files with 14 additions and 4 deletions

View File

@ -95,6 +95,10 @@ New Features
15. SOLR-273: Added hl.maxAnalyzedChars highlighting parameter, defaulting to 15. SOLR-273: Added hl.maxAnalyzedChars highlighting parameter, defaulting to
50k (klaas) 50k (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 behavior Changes in runtime behavior
Optimizations Optimizations

View File

@ -180,9 +180,13 @@
is requested, a superset of the requested number of document ids is requested, a superset of the requested number of document ids
are collected. For example, if a search for a particular query are collected. For example, if a search for a particular query
requests matching documents 10 through 19, and queryWindowSize is 50, requests 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 further
requests in that range can be satisfied via the cache. --> requests 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) <!-- This entry enables an int hash representation for filters (DocSets)
when the number of items in the set is less than maxSize. For smaller when the number of items in the set is less than maxSize. For smaller

View File

@ -259,6 +259,7 @@ public class SolrIndexSearcher extends Searcher implements SolrInfoMBean {
private static boolean useFilterForSortedQuery=SolrConfig.config.getBool("query/useFilterForSortedQuery", false); private static boolean useFilterForSortedQuery=SolrConfig.config.getBool("query/useFilterForSortedQuery", false);
private static int queryResultWindowSize=SolrConfig.config.getInt("query/queryResultWindowSize", 1); 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 { 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); out.docList = superset.subset(offset,len);
} }
// lastly, put the superset in the cache // lastly, put the superset in the cache if the size is less than or equal
if (key != null) { // to queryResultMaxDocsCached
if (key != null && superset.size() <= queryResultMaxDocsCached) {
queryResultCache.put(key, superset); queryResultCache.put(key, superset);
} }
} }