61_索引管理_快速上機動手實戰建立、修改以及刪除索引

5765809發表於2024-10-02

1、為什麼我們要手動建立索引?

2、建立索引

建立索引的語法

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"
}
}
}
}
}

3、修改索引

PUT /my_index/_settings
{
"number_of_replicas": 1
}

4、刪除索引

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

elasticsearch.yml
action.destructive_requires_name: true

相關文章