의미 | Method | URL | BODY | |
http://localhost:9200 | ||||
생성 | id로 도큐먼트 생성 | POST, PUT | /books/book/1 | { "title" : "Elasticsearch Guide", "author" : "Kim", "date" : "2014-05-01", "pages" : 250 } |
도큐먼트 데이터 확인 | GET | /books/book/1 | ||
임의의 id로 도큐먼트 생성 | POST (PUT은 안됨) |
/books/book | { "title" : "Elasticsearch Guide", "author" : "Kim", "started" : "2014-05-1", "pages" : 250 } |
|
도큐먼트 수정 | PUT | /books/book/1 | { "title" : "Elasticsearch Guide", "author" : [ "Kim", "Lee" ], "date" : "2014-05-01", "pages" : 300 } |
|
삭제 | 특정
id 삭제 (_source가 빈값으로 update) 메타정보 남아있음 |
DELETE | /books/book/1 | |
타입삭제 = 모든 타큐먼트 삭제 메타정보 삭제 |
DELETE | /books/book | ||
인덱스 삭제 | DELETE | /books | ||
수정 | category 필드 추가 | POST | /books/book/1/_update | { "doc" : { "category" : "ICT" } } |
author 필드를 Lee로 변경 | POST | /books/book/1/_update | { "doc" : { "author" : "Lee" } } |
|
pages 필드에 50을 더함 | POST | /books/book/1/_update | { "script" : "ctx._source.pages += 50" } |
|
author 필드의 값 "Lee"를 배열 ["Lee"]로 변경 |
POST | /books/book/1/_update | { "doc" : { "author" : ["Lee"] } } |
|
author 필드에 값 "Kim"을 추가 | POST | /books/book/1/_update | { "script" : "ctx._source.author += new_author", "params" : { "new_author" : "Kim" } } |
|
author 필드가 "Kim"을 포함하는 경우 pages 필드값을 100으로 변경 |
POST | /books/book/1/_update | { "script" : "if(ctx._source.author.contains(auth)) { ctx._source.pages = 100 } else { ctx._source.pages = 200 }", "params" : { "auth" : "Kim" } } |
|
pages 필드가 100 이하일 때 도큐먼트 삭제 |
POST | /books/book/1/_update | { "script" : "ctx._source.pages <= page_cnt ? ctx.op = \"delete\" : ctx.op = \"none\"", "params" : { "page_cnt" : 100 } } |
|
도큐먼트가 없다면 도큐먼트 생성. 도큐먼트가 있다면 counter 필드 1 증가 |
POST | /books/book/1/_update | { "script" : "ctx._source.counter += count", "params" : { "count" : 1 }, "upsert" : { "counter" : 0 } } |
|
벌크를 이용한 대량 insert | POST | /_bulk | {
"index" : { "_index" : "books",
"_type" : "book", "_id" : "1" }
} { "title" : "Elasticsearch Guide", "author" : "Kim", "pages" : 250 } { "index" : { "_index" : "books", "_type" : "book", "_id" : "2" } } { "title" : "Elasticsearch Easy Guide", "author" : "Lee", "pages" : 300 } |
|
_source 데이터만 확인 | GET | /books/book/1/_source | ||
json 결과를 보기좋게 줄바꿈해줌 | ?pretty=true 또는 ?pretty |
기타 도서 리뷰/시작하세요 엘라스틱서치