Avoiding caching of rare filters to improve the performance
Imagine that some of the filters you use in your queries are not good candidates for caching. You might wonder why—for example, do those filters have date and time with seconds or are spatial filters scattered all over the world? Such filters are quite unique, and thus when they are put into the cache, they are very rarely reused and thus they are more or less useless. Caching such filters is a waste of memory and CPU cycles. Is there something you can do to avoid filter queries caching? Yes, there is a way, and this recipe will show you how to do it.
How to do it...
Let's assume we have the following query being used to get the information we need:
q=solr+cookbook&fq=category:books&fq=date:[2014-06-12T13:22:12Z+TO+2014-07-11T11:24:54Z]
The filter query we don't want to cache is the one filtering our documents on the basis of the date
field. Of course, even though we don't want that filter to be cached, we still want the filtering...