# 创建 索引为megacorp 类型为 employee
PUT /megacorp/_create/1
{
"first_name": "John",
"last_name": "Smith",
"age": 25,
"about": "I love to go rock climbing",
"interests": [
"sports",
"music"
]
}
{
"_index" : "megacorp",
"_type" : "_doc",
"_id" : "1",
"_version" : 1,
"_seq_no" : 0,
"_primary_term" : 1,
"found" : true,
"_source" : {
"first_name" : "John",
"last_name" : "Smith",
"age" : 25,
"about" : "I love to go rock climbing",
"interests" : [
"sports",
"music"
]
}
}
修改文档
修改文档与创建文档类似,您可以选择PUT 或者POST,参数如下
{index}/_doc/{id}
这里我们将上面创建的文档about字段内添加 !
POST /megacorp/_doc/1
{
"first_name": "John",
"last_name": "Smith",
"age": 25,
"about": "I love to go rock climbing!",
"interests": [
"sports",
"music"
]
}