In Solr there are three types of built-in caches. Application performance can be enhanced considerably if these caches are set up properly.
Solr caches should be carefully used after enough consideration given to the actual usage of the application. Let us take a closer look at the 3 caches.
FilterCache: This cache will not order the returned documents and so is not appropriate for caching a query that relies on relevance or sort fields. FilterCache is based on unordered document ids. It is used for caching filter queries. It also stores information to filter out the right documents across the entire index for a particular query.
QueryCache: The optimal size of this cache should be decided based on the results of the common queries that are cached. QueryCache is based on ordered document ids. It is used for caching the results of normal queries. It also requires much less RAM compared to FilterCache because it only caches the returned documents, while the FilterCache caches the results for the whole index.
DocumentCache: This cache stores stored fields that increases speed of retrieval. Solr caches documents in memory so that no request has to use disk space for stored fields. This can be very valuable as stored fields are most often used for hit list displays. The size of this cache should be set to at least
* , in order to ensure that Solr does not need to re-fetch a document during a request.
Some Important Points to Note
1. Remember to check 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.
2. 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. Also, remember to finally check the Solr Wiki on SolrCaching and be sure to use the appropriate settings for best performance.
Using Solr caches can greatly improve enterprise search application performance