创建一个索引,包含2个分片1份副本(settings),指定了2个字段类型(mappings) 。
PUT greeting
{
"settings" : {
"number_of_shards" : 2,
"number_of_replicas" : 1
},
"mappings" : {
"_doc" : {
"properties" : {
"email" : { "type" : "keyword" },
"message" : { "type" : "text" }
}
}
}
}
POST book/_doc
{
"email" : "xxxx@qq.com",
"message" : "hello world"
}
POST book/_doc/1
{
"email" : "xxxx@qq.com",
"message" : "hello world"
}
POST greeting/_bulk
{ "index" : { "_type" : "_doc"} }
{ "email" : "xxxx@qq.com","message":"hello1" }
{ "index" : { "_type" : "_doc"} }
{ "email" : "yyyy@qq.com","message":"hello2" }
{ "index" : { "_type" : "_doc"} }
{ "email" : "zzzz@qq.com","message":"hello3" }
{ "index" : { "_type" : "_doc"} }
{ "email" : "aaaa@qq.com","message":"hello4" }
GET book/_doc/1
GET /_mget
{
"docs" : [
{
"_index" : "book1",
"_type" : "_doc",
"_id" : "1"
},
{
"_index" : "book2",
"_type" : "_doc",
"_id" : "2"
}
]
}