-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Description
Support for caching queries including scripts:
Although the documentation for the shard request query currently says:
If your query uses a script whose result is not deterministic (e.g. it uses a random function or references the current time) you should set the request_cache flag to false to disable caching for that request
In practice the cache is skipped whenever ScriptService is used
This is intentional, per @jimczi:
this is intentional ... we cannot ensure that the result is deterministic.
An alternative (which per the docs seems consistent with how some other scenarios are handled) would be to default to skipping the cache in such cases but allow use of the existing request_cache=true param for clients to declare their script is deterministic and can be cached
Note that scripted aggregations are often very expensive and therefore great candidates to be cached!