본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Index Segments API

원문 보기 위키 갱신

Segment API는 인덱스 샤드 안의 Lucene 세그먼트에 대한 세부 정보와 데이터 스트림의 백킹 인덱스에 대한 정보를 제공해요.

출처: OpenSearch 문서

본문

엔드포인트 (Endpoints)

GET /{index}/_segments
GET /_segments

경로 매개변수 (Path parameters)

다음 표는 사용할 수 있는 경로 매개변수를 나열한 것이에요. 모든 경로 매개변수는 선택 사항이에요.

| 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)

모든 쿼리 매개변수는 선택 사항이에요.

| Parameter | Data type | Description | | allow_no_indices | Boolean | Whether to ignore wildcards that don’t match any indexes. Default is true. | | expand_wildcards | String | Specifies the type of index that wildcard expressions can match. Supports comma-separated values. Valid values are all (match any index), open (match open, non-hidden indexes), closed (match closed, non-hidden indexes), hidden (match hidden indexes), and none (deny wildcard expressions). Default is open. | | 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. | | verbose | Boolean | When true, provides information about Lucene’s memory usage. Default is false. |

예제 요청 (Example requests)

다음 예제 요청들은 Segment API 사용법을 보여줘요.

특정 데이터 스트림이나 인덱스 (Specific data stream or index)

GET /index1/_segments
response = client.indices.segments(
index = "index1"
)

여러 데이터 스트림과 인덱스 (Several data streams and indexes)

GET /index1,index2/_segments
response = client.indices.segments(
index = "index1,index2"
)

클러스터의 모든 데이터 스트림과 인덱스 (All data streams and indexes in a cluster)

GET /_segments
response = client.indices.segments()

예제 응답 (Example response)

{
"_shards": ...
"indices": {
"test": {
"shards": {
"0": [
{
"routing": {
"state": "STARTED",
"primary": true,
"node": "zDC_RorJQCao9xf9pg3Fvw"
},
"num_committed_segments": 0,
"num_search_segments": 1,
"segments": {
"_0": {
"generation": 0,
"num_docs": 1,
"deleted_docs": 0,
"size_in_bytes": 3800,
"memory_in_bytes": 1410,
"committed": false,
"search": true,
"version": "7.0.0",
"compound": true,
"attributes": {
}
}
}
}
]
}
}
}
}

응답 본문 필드 (Response body fields)

| Parameter | Data type | Description | | segment | String | The name of the segment used to create internal file names in the shard directory. | | generation | Integer | The generation number, such as 0, incremented for each written segment and used to name the segment. | | num_docs | Integer | The number of documents, obtained from Lucene. Nested documents are counted separately from their parents. Deleted documents, as well as recently indexed documents that are not yet assigned to a segment, are excluded. | | deleted_docs | Integer | The number of deleted documents, obtained from Lucene, which may not match the actual number of delete operations performed. Recently deleted documents that are not yet assigned to a segment are excluded. Deleted documents are automatically merged when appropriate. OpenSearch will occasionally delete extra documents in order to track recent shard operations. | | size_in_bytes | Integer | The amount of disk space used by the segment, for example, 50kb. | | memory_in_bytes | Integer | The amount of segment data, measured in bytes, that is kept in memory to facilitate efficient search operations, such as 1264. A value of -1 indicates that OpenSearch was unable to compute this number. | | committed | Boolean | When true, the segments are synced to disk. Segments synced to disk can survive a hard reboot. If false, then uncommitted segment data is stored in the transaction log as well so that changes can be replayed at the next startup. | | search | Boolean | When true, segment search is enabled. When false, the segment may have already been written to disk and require a refresh in order to be searchable. | | version | String | The Lucene version used to write the segment. | | compound | Boolean | When true, indicates that Lucene merged all segment files into one file in order to save any file descriptions. | | attributes | Object | Shows if high compression was enabled. |

필요한 권한 (Required permissions)

Security 플러그인을 사용한다면 적절한 권한을 확인하세요: indices:monitor/segments

더 알아보기 (Learn more)