---
type: api
title: Clear the cache
description: **All methods and paths for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/operation/operation-searchable-snapshots-clear-cache
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/operation/operation-searchable-snapshots-clear-cache
products:
  - Elasticsearch
---

# Clear the cache


Availability: 7.10+

## Paths

- `POST` `/{index}/_searchable_snapshots/cache/clear`
- `POST` `/_searchable_snapshots/cache/clear`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/authentication#apikeyauth)
- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/authentication#basicauth)
- [Bearer auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/authentication#bearerauth)

#### Path Parameters

- `index` (union IndexName | [] IndexName) — optional, leave it out to use `/_searchable_snapshots/cache/clear`
  A comma-separated list of data streams, indices, and aliases to clear from the cache.
It supports wildcards (`*`).

## Description

Clear indices and data streams from the shared cache for partially mounted indices.

## Required authorization

* Index privileges: `manage`
* Cluster privileges: `manage`

[More about searchable snapshots](https://www.elastic.co/docs/deploy-manage/tools/snapshot-and-restore/searchable-snapshots)

## Query String Parameters

- `expand_wildcards` (string ExpandWildcards · default: open)
  Whether to expand wildcard expression to concrete indices that are open, closed or both

Supported values include:
  - `all`: Match any data stream or index, including hidden ones.
  - `open`: Match open, non-hidden indices. Also matches any non-hidden data stream.
  - `closed`: Match closed, non-hidden indices. Also matches any non-hidden data stream. Data streams cannot be closed.
  - `hidden`: Match hidden data streams and hidden indices. Must be combined with `open`, `closed`, or `both`.
  - `none`: Wildcard expressions are not accepted.
  Values: `all`, `open`, `closed`, `hidden`, `none`
- `allow_no_indices` (boolean)
  A setting that does two separate checks on the index expression.
If `false`, the request returns an error (1) if any wildcard expression
(including `_all` and `*`) resolves to zero matching indices or (2) if the
complete set of resolved indices, aliases or data streams is empty after all
expressions are evaluated. If `true`, index expressions that resolve to no
indices are allowed and the request returns an empty result.
- `ignore_unavailable` (boolean)
  If `false`, the request returns an error if it targets a concrete (non-wildcarded)
index, alias, or data stream that is missing, closed, or otherwise unavailable.
If `true`, unavailable concrete targets are silently ignored.

## Response

`application/json`

Type: `object`

## Code Examples

#### Console

```console
POST /my-index/_searchable_snapshots/cache/clear
```

#### JavaScript

```javascript
const response = await client.searchableSnapshots.clearCache({
  index: "my-index",
});
```

#### Python

```python
resp = client.searchable_snapshots.clear_cache(
    index="my-index",
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/my-index/_searchable_snapshots/cache/clear" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.searchableSnapshots().clearCache(c -> c
    .index("my-index")
);
```

#### C#

```c#
var response = await client.SearchableSnapshots
    .ClearCacheAsync(d1 => d1
        .Indices(new[] { "my-index" })
    );
```

#### PHP

```php
$resp = $client->searchableSnapshots()->clearCache([
    "index" => "my-index",
]);
```

#### Ruby

```ruby
response = client.searchable_snapshots.clear_cache(
  index: "my-index"
)
```

