创建、修改以及删除索引

创建、修改以及删除索引

1、创建索引

创建索引的语法

PUT /my_index
{
​ “settings”: { … any settings … },
​ “mappings”: {
​ “type_one”: { … any mappings … },
​ “type_two”: { … any mappings … },
​ …
​ }
}

创建索引的示例

PUT /my_index
{
“settings”: {
​ “number_of_shards”: 1,
​ “number_of_replicas”: 0
},
“mappings”: {
​ “my_type”: {
​ “properties”: {
​ “my_field”: {
​ “type”: “text”
​ }
​ }
​ }
}
}

2、修改索引

PUT /my_index/_settings
{
​ “number_of_replicas”: 1
}

3、删除索引

DELETE /my_index
DELETE /index_one,index_two
DELETE /index_*
DELETE /_all

可以在elasticsearch.yml中配置
action.destructive_requires_name: true

禁用DELETE /_all 操作,只能指定操作

打赏
  • 版权声明: 本博客所有文章除特别声明外,著作权归作者所有。转载请注明出处!
  • © 2020 John Doe
  • Powered by Hexo Theme Ayer
  • PV: UV:

请我喝杯咖啡吧~

支付宝
微信