Reduce cold query latency: Warm Slice
In a storage-compute separation architecture, all index data is persistently stored in Object Storage Service (OSS), and the query layer loads data into memory and the local SSD cache on demand. With the _warm_slice operation, you can proactively load the index data of a specified slice into the query-layer cache before a known burst of access arrives, which reduces the latency of the first query against cold data.
All API examples in this topic provide CONSOLE / CURL / GO / PYTHON / JAVASCRIPT / JAVA code tabs (CONSOLE requests can be copied directly into Kibana Dev Tools). The other SDK examples reuse the Quick start environment variables and the client instance initialized there, and use the collection described in Single-table mode without slices: Default Slice as an example, which is the products collection with the main slice.
1. Use cases and the difference between cold and warm access

Access state | How it works | Recommendation |
Warm access | The index data of the target slice is already in the query-layer cache, so requests hit memory or the local SSD directly and avoid remote reads. | Slices that are accessed frequently stay warm automatically (for cold and warm query latency, see Performance reference). |
Cold access | A slice that has not been accessed for a long time, or that was just switched to, must load index ranges from object storage on demand for the first query. | The first query is slower than a warm query. After the data is loaded, subsequent queries reuse the cache. |
Proactive prewarming ( | Before users log in, a campaign starts, or a batch evaluation runs, proactively preload the vector and index data of the target slice. | Prewarm on demand only the key slices that are about to receive concentrated access, which reduces first-query latency spikes. |
For example, in a multi-tenant AI knowledge base, when an employee of a company opens the after-sales knowledge base page, the business backend first sends an asynchronous POST /kb/_warm_slice?_slice=tenant-a request. The index is loaded in the background while the user types a question, which reduces the cold-load latency of the first RAG search.
2. Run cache prewarming (_warm_slice)
For online business scenarios that trigger prewarming, such as a user login, use the default asynchronous mode (wait_for_completion=false). The operation immediately returns a task ID without blocking the business request. For batch processing or stress test scripts that must confirm the prewarming is complete before they run queries, pass wait_for_completion=true&timeout=25s to use the synchronous wait mode (note that the server-side timeout must be shorter than the client-side request_timeout). After the prewarming completes, the operation returns the prewarming statistics:
URL query parameters (POST /{collection}/_warm_slice):
Parameter | Required | Default | Description |
| Yes | None | The name of the single slice to prewarm. Pass one of the two parameters. |
| No |
| Specifies whether to wait synchronously for the prewarming result. The default value |
| No | None | The maximum time to wait synchronously, such as |
| No |
| Specifies whether to persist the task result when you submit the task asynchronously ( |
CONSOLE
POST /products/_warm_slice?_slice=main&wait_for_completion=true&timeout=25sCURL
curl -u "$ES_USER:$ES_PASSWORD" -X POST \
"$ES_ENDPOINT/products/_warm_slice?_slice=main&wait_for_completion=true&timeout=25s"GO
req, _ := http.NewRequestWithContext(ctx, "POST",
"/products/_warm_slice?_slice=main&wait_for_completion=true&timeout=25s", nil)
resp, err := client.Perform(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()PYTHON
warm_stats = client.perform_request(
"POST",
"/products/_warm_slice",
params={"_slice": "main", "wait_for_completion": "true", "timeout": "25s"},
)
print(warm_stats)JAVASCRIPT
const warmStats = await client.transport.request({
method: 'POST',
path: '/products/_warm_slice',
querystring: { _slice: 'main', wait_for_completion: true, timeout: '25s' },
})
console.log(warmStats)JAVA
Request warmReq = new Request("POST", "/products/_warm_slice");
warmReq.addParameter("_slice", "main");
warmReq.addParameter("wait_for_completion", "true");
warmReq.addParameter("timeout", "25s");
Response warmResp = restClient.performRequest(warmReq);
System.out.println(EntityUtils.toString(warmResp.getEntity()));A typical response in synchronous mode:
{
"_shards": { "total": 1, "successful": 1, "failed": 0 },
"segments_matched": 1,
"ranges_requested": 8,
"ranges_warmed": 8,
"ranges_skipped": 0,
"bytes_requested": 661,
"docs_read": 2
}In synchronous mode, confirm that _shards.failed == 0 and ranges_skipped == 0 (for a non-empty slice, ranges_warmed > 0). These values indicate that all data ranges covered by this prewarming operation have been loaded into the query-layer cache (segments_matched is the number of matched segments, ranges_warmed is the number of loaded data ranges, and bytes_requested is the amount of prewarmed data).
3. Usage notes
Prewarm on demand instead of prewarming everything: Prewarming consumes query-layer cache space and object storage read bandwidth. Run it only on the key slices that are about to be queried intensively, and avoid indiscriminately prewarming a large number of cold slices.
Prewarm only searchable data: Newly written data becomes searchable only after the background refresh completes a few seconds later. After the refresh, run
_warm_sliceto prewarm this new data.The cache is managed dynamically based on access frequency: The query-layer cache evicts entries based on access frequency. A slice that has not been accessed for a long time is loaded again on demand at the next query.