The Caches API allows creating, viewing, updating and deleting cache information configured in the solrconfig.xml file for the collection.
Caches are used in Solr to store information from the index for faster responses if the index information is needed again. They are associated with a specific instance of a Solr IndexSearcher, and the cached information is valid as long as the IndexSearcher is valid. When a new IndexSearcher is opened, it is usually auto-warmed (pre-populated) with data from the previous cache. The settings on this page help define the size of caches and how they are used to auto-warm a new IndexSearcher.
These are advanced settings, and modifying them should be done with care.
API Entry Points
/api/collections/collection/caches: get details of all configured caches or create a new cache.
/api/collections/collection/chaches/name: update, delete, or get details for a specific cache.
Get a List of Caches and Attributes for a Collection
GET /api/collections/collection/caches
Input
Path Parameters
Enter path parameters.
| Key | Description |
|---|---|
| collection | The collection name. |
Query Parameters
None.
Output
Output Content
A JSON List of Maps mapping Collection keys to values.
| Key | Type | Description |
|---|---|---|
| name | string | The name of the cache. There are four known caches that are used in most implementations, which correspond to known Solr caches. These are:
|
| class | string | The cache implementation that's used for this cache. There are two available types, solr.LRUCache and solr.FastLRUCache. The other properties for the cache depend on the implementation that is used. See the following table for details of attributes that can be used for each cache implementation. The "LRU" part of the cache class name stands for "Least Recently Used". When an LRU cache fills up, the entry with the oldest last-accessed timestamp is removed to make room for the new entry. Frequently used items tend to remain cached, while less-used items will drop out of cache to be retrieved again later if they are needed. The FastLRUCache is meant to be lock-less, so is well-suited for caches that are hit several times in a request. |
| regenerator | string | A valid class name which specifies how to re-populate a new cache created by a new Searcher with old cache objects. Usually only declared for custom caches. |
solr.LRUCache Attributes
| Key | Type | Description |
|---|---|---|
| size | integer | The maximum number of entries in the cache. |
| initial_size | integer | The initial number of entries in the cache. |
| autowarm_count | integer | The number of entries to pre-populate from an old cache, or can be a percentage of the old cache. When a new Searcher is opened, it may be pre-populated with cached objects from the old Searcher. A best practice is to base the autowarm_count on how long it takes to autowarm a new Searcher. |
solr.FastLRUCache Attributes
| Key | Type | Description |
|---|---|---|
| size | integer | The maximum number of entries in the cache. |
| initial_size | integer | The initial number of entries in the cache. |
| autowarm_count | integer | The number of entries to pre-populate from an old cache, or can be a percentage of the old cache. When a new Searcher is opened, it may be pre-populated with cached objects from the old Searcher. A best practice is to base the autowarm_count on how long it takes to autowarm a new Searcher. |
| min_size | integer | When the cache hits it's size limit, this allows the cache to try to reduce to this value. The default is 0.9 * size. |
| acceptable_size | integer | When the cache removes old entries, it tries to achieve the min_size. If that is not possible, it tries to achieve acceptable_size instead. The default is 0.95 * size. |
| cleanup_thread | boolean | If set to true, cache cleanup will run in a dedicated separate thread. Very large cache sizes may perform better if they are in a dedicated thread. |
| show_items | integer | Used to debug what's contained in the cache. Will return the last N accessed items in the Solr Admin UI, using an MBeans Request Handler or JMX. A value of "-1" will display all items in the cache. |
Response Codes
200: OK
Examples
Input
curl http://localhost:8888/api/collections/collection1/caches
Output
[
{
"initial_size":"512",
"name":"document_cache",
"class":"solr.LRUCache",
"autowarm_count":"0",
"size":"512"
},
{
"initial_size":"512",
"name":"filter_cache",
"class":"solr.LRUCache",
"autowarm_count":"256",
"size":"512"
},
{
"initial_size":"512",
"name":"query_result_cache",
"class":"solr.LRUCache",
"autowarm_count":"256",
"size":"512"
},
{
"acceptable_size":null,
"initial_size":"10",
"name":"field_value_cache",
"class":"solr.FastLRUCache",
"cleanup_thread":null,
"autowarm_count":null,
"show_items":"-1",
"min_size":null,
"size":"10000"
}
]
Create a Cache and Attributes for a Collection
POST /api/collections/collection/caches
Input
Path Parameters
Enter path parameters.
| Key | Description |
|---|---|
| collection | The collection name. |
Query Parameters
None.
Input Content
A JSON List of Maps mapping Collection keys to values.
| Key | Type | Description |
|---|---|---|
| name | string | The name of the cache. There are four known caches that are used in most implementations, which correspond to known Solr caches. These are:
|
| class | string | The cache implementation that's used for this cache. There are two available types, solr.LRUCache and solr.FastLRUCache. The other properties for the cache depend on the implementation that is used. See the following table for details of attributes that can be used for each cache implementation. The "LRU" part of the cache class name stands for "Least Recently Used". When an LRU cache fills up, the entry with the oldest last-accessed timestamp is removed to make room for the new entry. Frequently used items tend to remain cached, while less-used items will drop out of cache to be retrieved again later if they are needed. The FastLRUCache is meant to be lock-less, so is well-suited for caches that are hit several times in a request. |
| regenerator | string | A valid class name which specifies how to re-populate a new cache created by a new Searcher with old cache objects. Usually only declared for custom caches. |
solr.LRUCache Attributes
| Key | Type | Description |
|---|---|---|
| size | integer | The maximum number of entries in the cache. |
| initial_size | integer | The initial number of entries in the cache. |
| autowarm_count | integer | The number of entries to pre-populate from an old cache, or can be a percentage of the old cache. When a new Searcher is opened, it may be pre-populated with cached objects from the old Searcher. A best practice is to base the autowarm_count on how long it takes to autowarm a new Searcher. If setting to a percentage, be sure to enclose the value in quotes, such as "autowarm":"50%". Setting to a number of entries does not require quotes. |
solr.FastLRUCache Attributes
| Key | Type | Description |
|---|---|---|
| size | integer | The maximum number of entries in the cache. |
| initial_size | integer | The initial number of entries in the cache. |
| autowarm_count | integer | The number of entries to pre-populate from an old cache, or can be a percentage of the old cache. When a new Searcher is opened, it may be pre-populated with cached objects from the old Searcher. A best practice is to base the autowarm_count on how long it takes to autowarm a new Searcher. If setting to a percentage, be sure to enclose the value in quotes, such as "autowarm":"50%". Setting to a number of entries does not require quotes. |
| min_size | integer | When the cache hits it's size limit, this allows the cache to try to reduce to this value. The default is 0.9 * size. |
| acceptable_size | integer | When the cache removes old entries, it tries to achieve the min_size. If that is not possible, it tries to achieve acceptable_size instead. The default is 0.95 * size. |
| cleanup_thread | boolean | If set to true, cache cleanup will run in a dedicated separate thread. Very large cache sizes may perform better if they are in a dedicated thread. |
| show_items | integer | Used to debug what's contained in the cache. Will return the last N accessed items in the Solr Admin UI, using an MBeans Request Handler or JMX. A value of "-1" will display all items in the cache. |
Output
Output Content
None.
Response Codes
List valid response codes and meaning
Examples
Input
curl -H 'Content-type: application/json' -d '{"name":"newcache","class":"solr.LRUCache","size":500}' \
http://localhost:8888/api/collections/collection1/caches
Output
None.
Update Cache Attributes
PUT /api/collections/collection/caches/name
Input
Path Parameters
Enter path parameters.
| Key | Description |
|---|---|
| collection | The collection name. |
| name | The cache name. |
Query Parameters
None.
Input Content
A JSON List of Maps mapping Collection keys to values.
| Key | Type | Description |
|---|---|---|
| name | string | The name of the cache. There are four known caches that are used in most implementations, which correspond to known Solr caches. These are:
|
| class | string | The cache implementation that's used for this cache. There are two available types, solr.LRUCache and solr.FastLRUCache. The other properties for the cache depend on the implementation that is used. See the following table for details of attributes that can be used for each cache implementation. The "LRU" part of the cache class name stands for "Least Recently Used". When an LRU cache fills up, the entry with the oldest last-accessed timestamp is removed to make room for the new entry. Frequently used items tend to remain cached, while less-used items will drop out of cache to be retrieved again later if they are needed. The FastLRUCache is meant to be lock-less, so is well-suited for caches that are hit several times in a request. |
| regenerator | string | A valid class name which specifies how to re-populate a new cache created by a new Searcher with old cache objects. Not needed for most implementations. |
solr.LRUCache Attributes
| Key | Type | Description |
|---|---|---|
| size | integer | The maximum number of entries in the cache. |
| initial_size | integer | The initial number of entries in the cache. |
| autowarm_count | integer | The number of entries to pre-populate from an old cache, or can be a percentage of the old cache. When a new Searcher is opened, it may be pre-populated with cached objects from the old Searcher. A best practice is to base the autowarm_count on how long it takes to autowarm a new Searcher. If setting to a percentage, be sure to enclose the value in quotes, such as "autowarm":"50%". Setting to a number of entries does not require quotes. |
solr.FastLRUCache Attributes
| Key | Type | Description |
|---|---|---|
| size | integer | The maximum number of entries in the cache. |
| initial_size | integer | The initial number of entries in the cache. |
| autowarm_count | integer | The number of entries to pre-populate from an old cache, or can be a percentage of the old cache. When a new Searcher is opened, it may be pre-populated with cached objects from the old Searcher. A best practice is to base the autowarm_count on how long it takes to autowarm a new Searcher. If setting to a percentage, be sure to enclose the value in quotes, such as "autowarm":"50%". Setting to a number of entries does not require quotes. |
| min_size | integer | When the cache hits it's size limit, this allows the cache to try to reduce to this value. The default is 0.9 * size. |
| acceptable_size | integer | When the cache removes old entries, it tries to achieve the min_size. If that is not possible, it tries to achieve acceptable_size instead. The default is 0.95 * size. |
| cleanup_thread | boolean | If set to true, cache cleanup will run in a dedicated separate thread. Very large cache sizes may perform better if they are in a dedicated thread. |
| show_items | integer | Used to debug what's contained in the cache. Will return the last N accessed items in the Solr Admin UI, using an MBeans Request Handler or JMX. A value of "-1" will display all items in the cache. |
Output
Output Content
None.
Examples
Input
curl -X PUT -H 'Content-type: application/json' -d '{"autowarm_count":"50%"}' \
http://localhost:8888/api/collections/collection1/caches/newcache
Output
None.
Delete a Cache
GET /api/collections/collection/caches/name
Input
Path Parameters
Enter path parameters.
| Key | Description |
|---|---|
| collection | The collection name. |
| name | The cache name. |
Query Parameters
None.
Output
Output Content
None.
Response Codes
None.
Examples
Input
curl -X DELETE http://localhost:8888/api/collections/collection1/caches/newcache