Popular APIs
Popular APIs
1.0에서 도입
이 페이지에는 자주 쓰는 OpenSearch 작업의 예시 요청이 담겨 있어요.
출처: 문서
본문
기본 설정이 아닌 인덱스 만들기 (Create index with non-default settings)
PUT my-logs
{
"settings": {
"number_of_shards": 4,
"number_of_replicas": 2
},
"mappings": {
"properties": {
"title": {
"type": "text"
},
"year": {
"type": "integer"
}
}
}
}
임의 ID로 문서 색인하기 (Index a document with a random ID)
POST my-logs/_doc
{
"title": "Your Name",
"year": "2016"
}
특정 ID로 문서 색인하기 (Index a document with a specific ID)
PUT my-logs/_doc/1
{
"title": "Weathering with You",
"year": "2019"
}
여러 문서를 한 번에 색인하기 (Index several documents at once)
요청 본문 끝의 빈 줄은 필수예요. _id 필드를 생략하면 OpenSearch가 임의 ID를 생성해요.
POST _bulk
{ "index": { "_index": "my-logs", "_id": "2" } }
{ "title": "The Garden of Words", "year": 2013 }
{ "index" : { "_index": "my-logs", "_id" : "3" } }
{ "title": "5 Centimeters Per Second", "year": 2007 }
모든 인덱스 나열하기 (List all indexes)
GET _cat/indices?v&expand_wildcards=all
패턴과 일치하는 모든 인덱스 열기 또는 닫기 (Open or close all indexes that match a pattern)
POST my-logs*/_open
POST my-logs*/_close
패턴과 일치하는 모든 인덱스 삭제하기 (Delete all indexes that match a pattern)
DELETE my-logs*
인덱스 별칭 만들기 (Create an index alias)
이 요청은 my-logs-2019-11-13 인덱스의 별칭 my-logs-today를 만들어요.
PUT my-logs-2019-11-13/_alias/my-logs-today
모든 별칭 나열하기 (List all aliases)
GET _cat/aliases?v
인덱스 또는 패턴과 일치하는 모든 인덱스 검색하기 (Search an index or all indexes that match a pattern)
GET my-logs/_search?q=test
GET my-logs*/_search?q=test
기본값을 포함한 클러스터 설정 가져오기 (Get cluster settings, including defaults)
GET _cluster/settings?include_defaults=true
디스크 워터마크(또는 다른 클러스터 설정) 바꾸기 (Change disk watermarks or other cluster settings)
PUT _cluster/settings
{
"transient": {
"cluster.routing.allocation.disk.watermark.low": "80%",
"cluster.routing.allocation.disk.watermark.high": "85%"
}
}
클러스터 건강 확인하기 (Get cluster health)
GET _cluster/health
클러스터의 노드 나열하기 (List nodes in the cluster)
GET _cat/nodes?v
노드 통계 가져오기 (Get node statistics)
GET _nodes/stats
리포지토리의 스냅샷 가져오기 (Get snapshots in a repository)
GET _snapshot/my-repository/_all
스냅샷 만들기 (Take a snapshot)
PUT _snapshot/my-repository/my-snapshot
스냅샷 복원하기 (Restore a snapshot)
POST _snapshot/my-repository/my-snapshot/_restore
{
"indices": "-.opendistro_security",
"include_global_state": false
}