创建文档
创建一个叫做 twitter 的索引(index),并插入一个文档(document) ,文档id为1
PUT twitter/_doc/1
{
“user”: “GB”,
“uid”: 1,
“city”: “Beijing”,
“province”: “Beijing”,
“country”: “China”
}
结果
{
“_index” : “twitter”, //索引
“type” : “doc”, //类型是文档
“_id” : “1”,//
“_version” : 11, //版本信息,被迭代的次数
“result” : “updated”,
“_shards” : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
“_seq_no” : 26,
“_primary_term” : 1
}
查看文档
GET twitter/_doc/1
结果
{
“_index” : “twitter”,
“type” : “doc”,
“_id” : “1”,
“_version” : 24,
“_seq_no” : 39,
“_primary_term” : 1,
“found” : true,
“_source” : {
"user" : "GB",
"uid" : 1,
"city" : "Beijing",
"province" : "Beijing",
"country" : "China"
}
}
只获取_source
GET twitter/_source/1
结果
{
“user” : “GB”,
“uid” : 1,
“city” : “Beijing”,
“province” : “Beijing”,
“country” : “China”
}
只获取 source 的部分字段
GET twitter/doc/1?source=city,age,province