You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ds...@apache.org on 2021/05/06 04:03:50 UTC

[solr] branch main updated: SOLR-14166: update and refactor docs on cache local-param (#113)

This is an automated email from the ASF dual-hosted git repository.

dsmiley pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new abdca25  SOLR-14166: update and refactor docs on cache local-param (#113)
abdca25 is described below

commit abdca25b86c32064689c749f53715e8eed04a1da
Author: David Smiley <ds...@apache.org>
AuthorDate: Thu May 6 00:03:39 2021 -0400

    SOLR-14166: update and refactor docs on cache local-param (#113)
    
    The "cache" is a local-param, not top level.  It's nearly always used with "fq" so move there.
    Update the fact that "cost" is just a hint now.
    spatial-search.adoc: remove PostFilter reference that is now inconsequential (a good thing).
---
 .../src/common-query-parameters.adoc               | 59 ++++++++++++----------
 .../src/query-settings-in-solrconfig.adoc          |  9 ++--
 solr/solr-ref-guide/src/spatial-search.adoc        |  2 -
 3 files changed, 37 insertions(+), 33 deletions(-)

diff --git a/solr/solr-ref-guide/src/common-query-parameters.adoc b/solr/solr-ref-guide/src/common-query-parameters.adoc
index d14b899..6ba0eee 100644
--- a/solr/solr-ref-guide/src/common-query-parameters.adoc
+++ b/solr/solr-ref-guide/src/common-query-parameters.adoc
@@ -123,6 +123,38 @@ fq=+popularity:[10 TO *] +section:0
 
 * As with all parameters: special characters in an URL need to be properly escaped and encoded as hex values. Online tools are available to help you with URL-encoding. For example: http://meyerweb.com/eric/tools/dencoder/.
 
+=== cache Local Parameter
+
+Solr caches the results of filter queries by default in the <<query-settings-in-solrconfig.adoc#filtercache,filter cache>>.
+To disable it, use the boolean `cache` <<local-parameters-in-queries.adoc#,local parameter>>, such as `fq={!geofilt cache=false}...`.
+Do this when you think a query is unlikely to be repeated.
+
+Non-cached filter queries also support the `cost` local parameter to provide a _hint_ as to the order in which they are evaluated.
+This allows you to order less expensive non-cached filters before expensive non-cached filters.
+At the Lucene layer, this maps to `TwoPhaseIterator.matchCost` if the query has a TPI.
+
+*Post Filters*: For very high cost filters, if `cache=false` _and_ `cost>=100`, _and_ the query implements the `PostFilter` interface, a Collector will be requested from that query and used to filter documents after they have matched the main query and all other filter queries.
+There can be multiple post filters; they are also ordered by cost.
+
+For most queries the default behavior is `cost=0`, but some types of queries (such as `{!frange}`) default to `cost=100`, because they are most efficient when used as a `PostFilter`.
+
+This is an example of 3 regular filters, where all matching documents generated by each are computed up front and cached independently:
+
+[source,text]
+q=some keywords
+fq=quantity_in_stock:[5 TO *]
+fq={!frange l=10 u=100}mul(popularity,price)
+fq={!frange cost=200 l=0}pow(mul(sum(1, query('tag:smartphone')), div(1,avg_rating)), 2.3)
+
+These are the same filters run without caching.
+The simple range query on the `quantity_in_stock` field will be run in parallel with the main query like a traditional Lucene filter, while the 2 `frange` filters will only be checked against each document has already matched the main query and the `quantity_in_stock` range query -- first the simpler `mul(popularity,price)` will be checked (because of its implicit `cost=100`) and only if it matches will the final very complex filter (with its higher `cost=200`) be checked.
+
+[source,text]
+q=some keywords
+fq={!cache=false}quantity_in_stock:[5 TO *]
+fq={!frange cache=false l=10 u=100}mul(popularity,price)
+fq={!frange cache=false cost=200 l=0}pow(mul(sum(1, query('tag:smartphone')), div(1,avg_rating)), 2.3)
+
 == fl (Field List) Parameter
 
 The `fl` parameter limits the information included in a query response to a specified list of fields. The fields must be either `stored="true"` or `docValues="true"``.`
@@ -274,33 +306,6 @@ The `wt` parameter selects the Response Writer that Solr should use to format th
 
 If you do not define the `wt` parameter in your queries, JSON will be returned as the format of the response.
 
-== cache Parameter
-
-Solr caches the results of all queries and filter queries by default. To disable result caching, set the `cache=false` parameter.
-
-You can also use the `cost` option to control the order in which non-cached filter queries are evaluated. This allows you to order less expensive non-cached filters before expensive non-cached filters.
-
-For very high cost filters, if `cache=false` and `cost>=100` and the query implements the `PostFilter` interface, a Collector will be requested from that query and used to filter documents after they have matched the main query and all other filter queries. There can be multiple post filters; they are also ordered by cost.
-
-For most queries the default behavior is `cost=0`, but some types of queries (such as `{!frange}`) default to `cost=100`, because they are most efficient when used as a `PostFilter`.
-
-This is an example of 3 regular filters, where all matching documents generated by each are computed up front and cached independently:
-
-[source,text]
-q=some keywords
-fq=quantity_in_stock:[5 TO *]
-fq={!frange l=10 u=100}mul(popularity,price)
-fq={!frange cost=200 l=0}pow(mul(sum(1, query('tag:smartphone')), div(1,avg_rating)), 2.3)
-
-These are the same filters run without caching.
-The simple range query on the `quantity_in_stock` field will be run in parallel with the main query like a traditional Lucene filter, while the 2 `frange` filters will only be checked against each document has already matched the main query and the `quantity_in_stock` range query -- first the simpler `mul(popularity,price)` will be checked (because of its implicit `cost=100`) and only if it matches will the final very complex filter (with its higher `cost=200`) be checked.
-
-[source,text]
-q=some keywords
-fq={!cache=false}quantity_in_stock:[5 TO *]
-fq={!frange cache=false l=10 u=100}mul(popularity,price)
-fq={!frange cache=false cost=200 l=0}pow(mul(sum(1, query('tag:smartphone')), div(1,avg_rating)), 2.3)
-
 == logParamsList Parameter
 
 By default, Solr logs all parameters of requests. Set this parameter to restrict which parameters of a request are logged. This may help control logging to only those parameters considered important to your organization.
diff --git a/solr/solr-ref-guide/src/query-settings-in-solrconfig.adoc b/solr/solr-ref-guide/src/query-settings-in-solrconfig.adoc
index 944143f..546b8af 100644
--- a/solr/solr-ref-guide/src/query-settings-in-solrconfig.adoc
+++ b/solr/solr-ref-guide/src/query-settings-in-solrconfig.adoc
@@ -49,15 +49,14 @@ A `maxIdleTime` attribute controls the automatic eviction of entries that haven'
 
 The `maxRamMB` attribute limits the maximum amount of memory a cache may consume. When both `size` and `maxRamMB` limits are specified the `maxRamMB` limit will take precedence and the `size` limit will be ignored.
 
-All caches can be disabled using the parameter `enabled` with a value of `false`. Caches can also be disabled on a query-by-query basis with the `cache` parameter, as described in the section <<common-query-parameters.adoc#cache-parameter,cache Parameter>>. 
-
 Details of each cache are described below.
 
 === filterCache
 
-This cache is used by `SolrIndexSearcher` for filters (DocSets) for unordered sets of all documents that match a query. The numeric attributes control the number of entries in the cache.
+This cache holds parsed queries paired with an unordered set of all documents that match it.  Unless such a set is trivially small, the set implementation is a bitset.
 
-The most typical way Solr uses the `filterCache` is to cache results of each `fq` search parameter, though there are some other cases as well. Subsequent queries using the same parameter filter query result in cache hits and rapid returns of results. See <<searching.adoc#,Searching>> for a detailed discussion of the `fq` parameter. Another Solr feature using this cache is the `filter(...)` syntax in the default Lucene query parser.
+The most typical way Solr uses the `filterCache` is to cache results of each `fq` (filter query) search parameter, though there are some other cases as well. Subsequent queries using the same filter query result in cache hits and rapid returns of results. See <<searching.adoc#,Searching>> for a detailed discussion of the `fq` parameter. Another Solr feature using this cache is the `filter(...)` syntax in the default Lucene query parser.
+Use of this cache can be disabled for a `fq` using the <<common-query-parameters.adoc#cache-local-parameter,cache local-parameter>>.
 
 Solr also uses this cache for faceting when the configuration parameter `facet.method` is set to `fc`. For a discussion of faceting, see <<searching.adoc#,Searching>>.
 
@@ -84,6 +83,8 @@ This cache holds the results of previous searches: ordered lists of document IDs
 
 The `queryResultCache` has an optional setting to limit the maximum amount of RAM used (`maxRamMB`). This lets you specify the maximum heap size, in megabytes, used by the contents of this cache. When the cache grows beyond this size, oldest accessed queries will be evicted until the heap usage of the cache decreases below the specified limit. If a `size` is specified in addition to `maxRamMB` then only the heap usage limit is respected.
 
+Use of this cache can be disabled on a query-by-query basis in `q` using the <<common-query-parameters.adoc#cache-local-parameter,cache local-parameter>>.
+
 [source,xml]
 ----
 <queryResultCache class="solr.CaffeineCache"
diff --git a/solr/solr-ref-guide/src/spatial-search.adoc b/solr/solr-ref-guide/src/spatial-search.adoc
index 30acd01..050ac40 100644
--- a/solr/solr-ref-guide/src/spatial-search.adoc
+++ b/solr/solr-ref-guide/src/spatial-search.adoc
@@ -158,8 +158,6 @@ If you know the filter query (be it spatial or not) is fairly unique and not lik
 [source,text]
 &q=...mykeywords...&fq=...someotherfilters...&fq={!geofilt cache=false}&sfield=store&pt=45.15,-93.85&d=5
 
-LLPSF does not support Solr's "PostFilter".
-
 == Distance Sorting or Boosting (Function Queries)
 
 There are four distance function queries: