Elasticsearch 의 기본 동작: 2016 - 4 - 6

 :        
curl -XPUT 'http://localhost:9200/blog/article/1' -d '{"title": "New
version of Elasticsearch released!", "content": "Version 2.2 released
today!", "priority": 10, "tags": ["announce", "elasticsearch", "release"]
}'
    ,    
{
"_index":"blog",
"_type":"article",
"
_id":"1",
"_version":1,
"_shards":{
"total":2,
"successful":1,
"failed":0},
"created":true
}
 .           
curl -XPOST 'http://localhost:9200/blog/article/' -d '{"title": "New
version of Elasticsearch released!", "content": "Version 2.2 released
today!", "priority": 10, "tags": ["announce", "elasticsearch", "release"]
}'
 :   POST          PUT   
    
{
"_index":"blog",
"_type":"article",
"_id":"AU1y-s6w2WzST_RhTvCJ",
"_version":1,
"_shards":{
"total":2,
"successful":1,
"failed":0},
"created":true
}
 .    
curl -XGET  http://localhost:9200/blog/article/1?pretty
{
  "_index" : "blog",
  "_type" : "article",
  "_id" : "1",
  "_version" : 2,
  "found" : true,
  "_source" : {
    "title" : "New version of Elasticsearch released!",
    "content" : "My quick brown fox eats rabbits on a regular basis.",
    "priority" : "7",
    "tags" : "2017-11-24"
  }
}
         ,       :
curl -XGET http://localhost:9200/blog/article/2?pretty
    :
{
  "_index" : "blog",
  "_type" : "article",
  "_id" : "2",
  "found" : false
}
 .    
              
curl -XPOST 'http://localhost:9200/blog/article/1/_update' -d '{
"script" : "ctx._source.content = new_content"
}'
 .    
curl -XDELETE 'localhost:9200/blog/article/1'
 .    
       ,         ,                             ,    。
curl -XPUT 'localhost:9200/blog/article/10' -d '{"title":"Test document"}'
curl -XPUT 'localhost:9200/blog/article/10' -d '{"title":"Updated test
document"}'
   : version 2
      ,       1,      。
curl -XDELETE 'localhost:9200/blog/article/10?version=1'
The response generated by Elasticsearch should be similar to the following one:
{
"error" : {
"root_cause" : [ {
"type" : "version_conflict_engine_exception",
"reason" : "[article][10]: version conflict, current [2], provided
[1]",
"shard" : 1,
"index" : "blog"
} ],
"type" : "version_conflict_engine_exception",
"reason" : "[article][10]: version conflict, current [2], provided
[1]",
"shard" : 1,
"index" : "blog"
},
"status" : 409
}

좋은 웹페이지 즐겨찾기