ELASTICSEARCH CRUD

ELASICSEARCH CRUD

ELASTICSEARCH에 Document(Row)를 삽입, 삭제, 조회

ELASTICSEARCH RDB CRUD
GET SELECT READ
PUT UPDATE UPDATE
POST INSERT CREATE
DELETE DELETE DELETE

Verify Index

curl -XGET localhost:9200/classes
curl -XGET localhost:9200/classes?pretty
  • ?pretty: JSON fotmatting

Create Index

curl -XPUT localhost:9200/classes
  • Success: {"acknowledged":true,"shards_acknowledged":true}

Delete Index

curl -XDELETE localhost:9200/classes
  • Success: {"acknowledged":true}

Create Document

curl -XPOST localhost:9200/classes/class/1/ -d '{"title":"A", "professor":"J"}'
  • Success: {"_index":"classes","_type":"class","_id":"1","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"created":true}

Create Document from File

curl -XPOST localhost:9200/classes/class/1/ -d @oneclass.json
  • Fail: {"error":{"root_cause":[{"type":"null_pointer_exception","reason":null}],"type":"null_pointer_exception","reason":null},"status":500}
  • Success: {"_index":"classes","_type":"class","_id":"1","_version":2,"result":"updated","_shards":{"total":2,"successful":1,"failed":0},"created":false}

oneclass.json

{
  "title" : "Machine Learning",
  "Professor" : "Minsuk Heo",
  "major" : "Computer Science",
  "semester" : ["spring", "fall"],
  "student_count" : 100,
  "unit" : 3,
  "rating" : 5
}
wget https://raw.githubusercontent.com/minsuk-heo/BigData/master/ch01/oneclass.json

results matching ""

    No results matching ""