curl -XGET 'http://localhost:9200/_cluster/health'
curl -XGET 'http://localhost:9200/_cluster/health?pretty'
{
"cluster_name" : "elasticsearch",
"status" : "yellow",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 10,
"active_shards" : 10,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 10,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 50.0
}
필자는 ebooks라는 인덱스를 미리 만들어 두었고, doc이란 type(table)이 있는 상태
curl -XGET 'http://localhost:9200/ebooks?pretty'
{
"ebooks" : {
"aliases" : { },
"mappings" : {
"doc" : {
"properties" : {
"author" : {
"type" : "text"
},
"body" : {
"type" : "text"
},
"book_id" : {
"type" : "integer"
},
"cover_img_src" : {
"type" : "text"
},
"id" : {
"type" : "integer"
},
"title" : {
"type" : "text"
}
}
}
},
"settings" : {
"index" : {
"creation_date" : "1599211840618",
"number_of_shards" : "5",
"number_of_replicas" : "1",
"uuid" : "RjSuEABHTgaKRt-ah8fuUA",
"version" : {
"created" : "6070199"
},
"provided_name" : "ebooks"
}
}
}
}
curl -XPOST http://localhost:9200/ebooks/doc/1 -d @/Users/kjsong/test.json -H 'Content-Type: application/json'
1번 id에 test.json의 내용을 post
{
"_index" : "ebooks",
"_type" : "doc",
"_id" : "1",
"_version" : 4,
"result" : "updated",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"_seq_no" : 1,
"_primary_term" : 1
}
curl -XGET 'http://localhost:9200/ebooks/doc/_count?pretty'
{
"count" : 2,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
}
}
1번 id document 삭제
curl -XDELETE http://localhost:9200/ebooks/doc/1