文档是具体的数据,一个文档有点像数据库中的一条记录,文档必须包含在一个索引中。
POST secisland2/_doc/
{
"message":"this is for update",
"name":"new name"
}
带自定义的_id:
POST secisland2/_doc/5
{
"message":"this is for update",
"name":"new name"
}
添加文档时,防止覆盖已存在的文档,可以通过_create加以限制。
POST secisland2/_doc/1/_create
{
"name":"update name"
}
GET secisland2/_search
GET secisland2/_doc/1
响应结果说明:
GET secisland2/_doc/10
GET secisland2/_doc/1?_source_includes=name,author
POST secisland2/_update/2
{"doc":{"field1":"field-1-1","field3":"field3"}}
POST secisland2/_doc/1
{
"name":"update name"
}
POST secisland2/_update/1
{
"script": {
"source": "ctx._source.author=\"liucc\""
}
}
POST secisland2/_update/1
{
"script": {
"source":"ctx._source.counter=2;ctx._source.author=\"liucc2\""
}
}
POST secisland2/_update/1
{
"script": {
"source":"ctx._source.remove(\"author\")"
}
}
DELETE secisland2/_doc/1
GET secisland2/_mget
{
"docs":[
{
"_id":1
},
{
"_id":5
}
]
}
GET secisland2/_mget
{
"ids":[1,5]
}
POST _bulk
{"index":{"_index":"secisland2","_id":2}}
{"field1":"value1","field2":"value2"}
{"update":{"_index":"secisland2","_id":2}}
{"doc":{"field1":"field1111"}}
{"create":{"_index":"secisland2","_id":3}}
{"title":"发布都有哪些","name":"文档管理"}
{"delete":{"_index":"secisland2","_id":3}}
index:创建或者更新文档
update:更新文档
create:创建文档
delete:删除文档