61.index CUD

主要知识点

  • 索引CUD

   

一、创建索引的语法

   

PUT /my_index

{

"settings": { ... any settings ... },

"mappings": {

"type_one": { ... any mappings ... },

"type_two": { ... any mappings ... },

...

}

}

   

创建索引的示例

   

PUT /company

{

"settings":{

"number_of_shards":1,

"number_of_replicas":0

},

"mappings": {

"employee": {

"properties": {

"name":{

"type":"text"

}

}

}

}

}

   

二、修改索引

   

PUT /company/_settings

{

"number_of_replicas": 1

}

   

三、删除索引

DELETE /my_index

DELETE /index_one,index_two

DELETE /index_*

DELETE /_all

   

四、其他

elasticsearch.yml中把action.destructive_requires_name: true,这样设置后就不能直接用delete /_all把所有的索引删除,必须指定索引名才能删除

posted @ 2018-02-26 19:58  outback123  阅读(128)  评论(0编辑  收藏  举报