Configuration : Configuring Search Queries : Adding a Query Cache
 
Adding a Query Cache
 
About Query Cache
Create and Manage a Query Cache
You can improve search performance by enabling the query cache, which resides on the Search API command of the Exalead CloudView search server.
The query cache contains a list of hits and facets associated with a specific query, available to users who enter the same query.
To count as an exact match, the query must:
Have the same q= (UQL) or eq= (ELLQL) value as the cached query.
Have the same values for all other parameters passed to the Search API.
About Query Cache
Create and Manage a Query Cache
About Query Cache
A query cache can be either:
Consistent: clears the existing cache every time the index is updated, which ensures up-to-date results but impacts performance for frequently changing indexes.
Time-based: keeps a query in cache for N seconds, this generates a new cache to create a continuous update of the cache at the risk of the occasional stale result.
Warm-Up Queries
Each query cache also includes the option to define warm-up queries for popular searches, which are automatically loaded into cache:
When the search server starts.
After each index update (consistent query caches only).
Every N seconds (time-based query caches only).
Sample Use Case
Imagine you have a search application that displays a sales dashboard for a chain of retail stores. Executives frequently want an overview of financial trends that includes all the stores in their search results. However, individual store managers want to see the latest sales figures for their store only.
In such a case, you could create two caches:
One to store user queries in a consistent cache.
Another to store warm-up queries in a time-based cache.
Create and Manage a Query Cache
Create a Query Cache
You can add multiple query caches to the same command.
1. In the Administration Console, go to Search > Search API.
2. Under Commands, select /search-api > Search cache.
3. Under Search cache, click Add search cache and create one of the following:
Consistent: creates a new cache every time the index is updated.
Time-based: keeps a query in cache for N seconds.
4. (Optional) Under warm-up queries, define one or more queries to cache automatically.
Enter the query and any parameters as they appear in the search URL.
For example, to search for "new york city" while restricting the search to the sl0 search logic, enter: q=new%20york%20city&logic=sl0
For details on available parameters, see Appendix - Search API Parameters.
(Optional) Modify the other configuration options from their default values.
5. Click Apply.
Store Warm-Up Queries Only in a Cache
1. In the search cache settings for your search-api command, clear the cache queries options.
Know if Your Query Comes from Cache
This procedure assumes that you have indexed documents.
1. In the browser, open the search-api service at BASEPORT +10 with your query or #all.
For example, http://localhost:10010/search-api/search?q=%23all
2. The search results <Stats> node returns:
When not cached: <Stats status="ok" queueTime="0" ... />
When cached: <Stats status="from_cache" cache="CACHE_NAME" .... />