Shard Request Cache and Scripts

Hi everyone,

I'm new to Elasticsearch and I've been trying to understand why my query is not being cached.

I've read the documentation (Shard request cache settings | Elasticsearch Guide [8.11] | Elastic ) several times but I couldn't find any evidence that queries containing scripts cannot be cached.

Sample request:

GET /my_index/_search?request_cache=true
{
"size": 0,
"aggs": {
"groupByOperator": {
"terms": {
"field": "operator",
"size": 10,
"order": {
"total": "desc"
}
},
"aggs": {
"total": {
"sum": {
"script": {
"source": "return doc['field1'].value + doc['field2'].value;"
}
}
}
}
}
}
}

Any idea?

Thanks.

it's correct that we don't cache scripts today since we can't guarantee that a user doesn't have any API calls in their scrips that violates the requirements for caching. In particular this is that scripts are idempotent. There are possibilities today to theoretically call a date API that takes now() into account. We might be able to revisit this behavior. Would you mind opening an issue on our github tracker and mention me there, the handle is the same

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.