创建索引
假设索引名是 movie :
PUT http://127.0.0.1:9200/movie?pretty
返回
{
"acknowledged": true,
"shards_acknowledged": true,
"index": "productsnew"
}
设置索引数据结构 指定 mapping 和 settings
PUT movie
{
"mappings" : {
"properties" : {
"name" : {
"type" : "keyword"
}
}
},
"settings" : {
"index" : {
"number_of_shards" : 1,
"number_of_replicas" : 2
}
}
}
查看索引信息
GET movie
返回
{
"movie" : {
"aliases" : { },
"mappings" : { },
"settings" : {
"index" : {
"creation_date" : "1572843447230",
"number_of_shards" : "1",
"number_of_replicas" : "1",
"uuid" : "AzEtRiBaQqO5JDN_l7WG-w",
"version" : {
"created" : "7020099"
},
"provided_name" : "movie"
}
}
}
}
创建文档时自动创建索引
当向一个不存在的索引中写入文档时,会自动创建索引。(注意不需要的话,要关闭此功能)
POST student/_doc/1
{
"name": "张三"
}
删除索引
DELETE movie
返回
{
"acknowledged": true
}
先记录这些,后面慢慢在补充