
索引管理的引入索引的格式索引管理 *** 作
创建索引修改索引打开/关闭索引删除索引查看索引
索引管理的引入PUT /customer/_doc/1
{
"name": "John Doe"
}
而这个index实际上已经自动创建了它里面的字段(name)的类型。我们不妨看下它自动创建的mapping:
{
"mappings": {
"_doc": {
"properties": {
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
第一个禁止自动创建索引,第二个是手动创建索引。
禁止自动创建索引
vi config/elasticsearch.yml
action.auto_create_index: false索引的格式
在请求体里面传入设置或类型映射,如下所示:
PUT /my_index
{
"settings": { ... any settings ... },
"mappings": {
"properties": { ... any properties ... }
}
}
settings: 用来设置分片,副本等配置信息mappings: 字段映射,类型等 索引管理 *** 作 创建索引
PUT /test-index-users
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1
},
"mappings": {
"properties": {
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"age": {
"type": "long"
},
"remarks": {
"type": "text"
}
}
}
}
修改索引
修改副本为0
PUT /test-index-users/_settings
{
"settings": {
"number_of_replicas": 0
}
}
打开/关闭索引
关闭索引
一旦索引被关闭,那么这个索引只能显示元数据信息,不能够进行读写 *** 作。
POST /test-index/_close
开启索引
删除索引POST /test-index/_open
查看索引DELETE /test-index
查看mapping
GET /index/_mapping
查看setting
GET /index/_setting
查看所有
GET /index
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)