There are three types of built-in caches in Solr. When these caches are set up correctly it can aid in improving application performance.
The three types of Solr caches should be carefully used after enough consideration given to the actual usage of the application. Let's take a look at them now.
- This cache stores information to filter out the right documents across the entire index for a particular query.
- This cache is based on unordered document ids. It is used for caching filter queries.
- This cache will not present the returned documents in a sequence and so, is not appropriate for caching a query that relies on relevance or sort fields.
- This cache requires much less RAM compared to FilterCache because it only caches the returned documents, while the FilterCache caches the results for the entire index.
- The optimal size of this cache should be decided based on the results of the common queries that are cached.
- This cache is based on ordered document ids.
- This is used for caching the results of normal queries.
- Solr caches documents in memory so that requests need not use disk space for stored fields.
- This is very useful since stored fields are most often used for hit list displays.
- The size of this cache should be set to at least * , so that Solr does not need to re-fetch a document during a request. This cache stores stored fields as well.
Some Important Points to Note
- Always check the cache statistics that is shown in the Solr admin webpage. Very low hit rates mean that the cache may be doing more harm than good. Very high eviction rate could mean that the cache is too small, and also may be doing more harm than good.
- Remember to check the Solr Wiki on SolrCaching and be sure to use the appropriate settings for best performance.
- Always be mindful of the autowarm value. This tells Solr how many entries to take from the old cache and put into the new one when a new view of the index is opened.
- The document cache cannot be autowarmed, while the other two require a large value that is big enough to give the caches a good filling.
Using Solr caches can greatly improve enterprise search application performance