Get Index API
get index API 작업은 하나 이상의 인덱스에 대한 정보(설정, 매핑, 별칭 포함)를 반환해요. 클러스터에 어떤 인덱스가 어떻게 구성되어 있는지 확인할 때 유용해요. 이 기능은 OpenSearch 1.0에서 처음 소개되었어요.
출처: OpenSearch 문서
본문
엔드포인트
GET /{index}
경로 매개변수
다음 표는 사용 가능한 경로 매개변수 목록이에요.
| Parameter | Required | Data type | Description | | index | Required | String | The name of the index to retrieve. You can specify a single index, a comma-separated list of indexes, or a wildcard expression. Use _all or * to retrieve information for all indexes in the cluster. |
쿼리 매개변수
다음 표는 사용 가능한 쿼리 매개변수 목록이에요. 모든 쿼리 매개변수는 선택 사항이에요.
| Parameter | Data type | Description | Default | | allow_no_indices | Boolean | Specifies whether to ignore wildcards that do not match any indexes. If false, the request returns an error when wildcards do not match any indexes. | true | | expand_wildcards | String | Specifies the types of indexes to which wildcard expressions can expand. Supports comma-separated values. Valid values are: - all: Match all indexes, including hidden indexes. - open: Match open indexes. - closed: Match closed indexes. - hidden: Match hidden indexes. Must be combined with open, closed, or both. - none: Do not accept wildcard expressions. | open | | flat_settings | Boolean | Specifies whether to return settings in flat format. When true, settings are returned in a flattened format (for example, "index.creation_date": "123456789"). When false, settings are returned in nested format (for example, "index": {"creation_date": "123456789"}). | false | | include_defaults | Boolean | Specifies whether to include default settings in the response. When true, the response includes default values for all settings, which can help you identify setting names and values to update. | false | | ignore_unavailable | Boolean | Specifies whether to ignore indexes that are unavailable (missing or closed). If true, missing or closed indexes are not included in the response. | false | | local | Boolean | Specifies whether to retrieve information from the local node only instead of from the cluster manager node. | false | | cluster_manager_timeout | String | The amount of time to wait for a connection to the cluster manager node. | 30s |
예제 요청
다음 예제 요청은 books 인덱스에 대한 정보를 조회해요:
GET /books
response = client.indices.get(
index = "books"
)
예제 응답
OpenSearch는 요청한 인덱스(들)에 대한 정보를 반환해요:
{
"books": {
"aliases": {},
"mappings": {},
"settings": {
"index": {
"replication": {
"type": "DOCUMENT"
},
"number_of_shards": "2",
"provided_name": "books",
"creation_date": "1778255937147",
"number_of_replicas": "1",
"uuid": "Onnd4TKBQMODrfvAvNXjAg",
"version": {
"created": "137277827"
}
}
}
}
}
flat_settings=true 쿼리 매개변수를 사용하면 설정이 평면화된(flattened) 형식으로 반환돼요:
{
"books": {
"aliases": {},
"mappings": {},
"settings": {
"index.creation_date": "1778255937147",
"index.number_of_replicas": "1",
"index.number_of_shards": "2",
"index.provided_name": "books",
"index.replication.type": "DOCUMENT",
"index.uuid": "Onnd4TKBQMODrfvAvNXjAg",
"index.version.created": "137277827"
}
}
}
응답 본문 필드
응답에는 각 인덱스에 대해 별도의 객체가 있고, 그 키는 인덱스 이름이에요. 각 인덱스 객체에는 다음 필드가 포함돼요.
| Field | Data type | Description | | aliases | Object | Index aliases associated with the index. Each key is an alias name, and each value is an alias configuration object. For more information, see Index aliases. | | mappings | Object | Field mappings for documents in the index. Defines the data type and properties for each field. For more information, see Mappings. | | settings | Object | Index settings that control index behavior, such as the number of shards and replicas. For more information, see Index settings. |
필요한 권한
Security 플러그인을 사용한다면 적절한 권한이 있는지 확인해 주세요: indices:admin/get.
더 알아보기 (Learn more)
인덱스 정보를 더 다양하게 활용하는 방법을 알고 싶다면 원문 OpenSearch 문서를 확인해 주세요.