Skip to content

Commit

Permalink
Add _flush API (#7217) (#7345)
Browse files Browse the repository at this point in the history
  • Loading branch information
opensearch-trigger-bot[bot] authored Jun 10, 2024
1 parent 31070ca commit 1971855
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions _api-reference/index-apis/flush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
layout: default
title: Flush
parent: Index APIs
nav_order: 36
---

# Flush

**Introduced 1.0**
{: .label .label-purple }

The Flush API stores all in-memory operations to segments on disk. Operations flushed to an index segment are no longer needed in transaction logs during a cluster restart because these operations are now stored in the Lucene index.

OpenSearch automatically performs flushes in the background based on conditions like transaction log size, which is controlled by the `index.translog.flush_threshold_size` setting. Use the Flush API sparingly, for example, for manual restarts or to free up memory.

## Path and HTTP methods

The Flush API supports the following paths:

```
GET /_flush
POST /_flush
GET /{index}/_flush
POST /{index}/_flush
```

## Path parameters

The following table lists the available path parameters. All path parameters are optional.

| Parameter | Data type | Description |
| :--- | :--- | :--- |
| `<index>` | String | A comma-separated list of indexes, data streams, or index aliases to which the operation is applied. Supports wildcard expressions (`*`). Use `_all` or `*` to specify all indexes and data streams in a cluster. |

## Query parameters

The Flush API supports the following query parameters.

| Parameter | Data type | Description |
| :--- | :--- | :--- |
| `allow_no_indices` | Boolean | When `false`, the request returns an error if any wildcard expression or index alias targets any closed or missing indexes. Default is `true`. |
| `expand_wildcards` | String | Specifies the types of indexes to which wildcard expressions can expand. Supports comma-separated values. Valid values are: <br> - `all`: Expand to all open and closed indexes, including hidden indexes. <br> - `open`: Expand to open indexes. <br> - `closed`: Expand to closed indexes. <br> - `hidden`: Include hidden indexes when expanding. Must be combined with `open`, `closed`, or both. <br> - `none`: Do not accept wildcard expressions. <br> Default is `open`. |
| `force` | Boolean | When `true`, forces a flush to occur even when no changes to the index exist in-memory. Default is `true`. |
| `ignore_unavailable` | Boolean | When `true`, OpenSearch ignores missing or closed indexes. If `false`, OpenSearch returns an error if the force merge operation encounters missing or closed indexes. Default is `false`. |
| `wait_if_ongoing` | Boolean | When `true`, the Flush API does not run while another flush request is active. When `false`, OpenSearch returns an error if another flush request is active. Default is `true`. |

## Example request: Flush a specific index

The following example flushes an index named `shakespeare`:

```
POST /shakespeare/_flush
```

## Example request: Flush all indexes

The following example flushes all indexes in a cluster:

```
POST /_flush
```

## Example response

OpenSearch responds with the number of shards that acknowledged the flush request, the number of shards that completed the request, and the number of shards that failed:

```
{
"_shards": {
"total": 10,
"successful": 10,
"failed": 0
}
}
```


0 comments on commit 1971855

Please sign in to comment.