BigData/ElasticSearch
ElasticSearch) 엘라스틱서치 기본 사용법
개발자웅이
2024. 8. 16. 17:40
centos7, 엘라스틱서치 7.5.1 기준입니다.
기본 사용법에 대해 알아보겠습니다.
명령어 | 설명 | 비고 |
curl http://localhost:9200/_cat/health?pretty | 클러스터 헬스체크 | |
curl http://localhost:9200/_cat/nodes | node 구성, 맨 오른쪽 노드명 옆에 * 이 있으면 현재 마스터노드 | |
curl -X PUT http://localhost:9200/test (인덱스명) | index 생성 | |
curl http://localhost:9200/_cat/indices?v | index 목록 | |
curl -X DELETE http://localhost:9200/test (인덱스명) | index 삭제 | |
curl -XPUT http://localhost:9200/item/_doc/1 -H 'Content-Type: application/json' -d' { "title": "테스트 제목", "message": "안녕하세요 Elasticsearch" }' |
document 생성 | document만들 때, 없는 index랑 type을 지정하면 자동으로 둘 다 만듬 curl -XPUT http://es주소:포트/인덱스명/타입명/번호 -H 'Content-Type: application/json' -d'입력할 JSON 데이터' |
curl -X GET http://localhost:9200/item/_search\?pretty | document 조회 | |
curl -XPUT http://localhost:9200/item/_doc/2 -H 'Content-Type: application/json' -d' { "title": "두 번째 행", "message": "안녕하세요 Elasticsearch" }' |
document 추가 | _doc뒤에 숫자(도큐먼트아이디)가 달라야 추가가됨. 같으면 기존꺼 덮어씌어짐 |
curl -X DELETE http://localhost:9200/item/_doc/3 | document 삭제 | curl -X DELETE http://es주소:포트/인덱스명/타입명/삭제할 번호 |
curl -X POST "localhost:9200/item/_update/1?pretty" -H 'Content-Type: application/json' -d ' { "doc": { "title": "수정된 제목" } }' |
document 수정 | 기존 필드 수정 |
감사합니다.
반응형