elasticsearch索引管理

来源:互联网 发布:矩阵计算中文第四版pdf 编辑:程序博客网 时间:2024/05/21 15:56

–查看集群健康状况
GET /_cluster/health

修改集群名称和节点名称,可以在配置文件elasticsearch.yml中修改:
cluster.name: testcluster
node.name: node-1

默认配置
–查看所有索引的分片设置情况
GET /_settings

–查看指定索引的分片设置情况
GET /testindex/_settings

系统会自带好些个系统索引,我的有11个之多,系统索引都是一个主分片,一个复制分片。

默认情况下,自己创建的索引,有5个主分片,有一个复制分片。

索引的创建与修改
系统默认会自动添加数据库和表,
如果要手动添加,需要在配置文件config/elasticsearch.yml中添加一行:
action.auto_create_index: false

禁止自动创建mapping:
index.mapper.dynamic : false

–创建只有一个主分片,没有复制分片的索引。
(注:在索引创建后,主分片个数不能修改)

PUT /testindex{    "settings": {        "number_of_shards" :   1,        "number_of_replicas" : 0    }}

–修改索引

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

–删除指定数据库testindex
DELETE /testindex

表结构的创建与修改
–建立一个新表testtable,只有一个字段message:

PUT testindex {  "mappings": {    "testtable": {      "properties": {        "message": {          "type": "text"        }      }    }  }}

–建立一个新表user,只有一个字段name

PUT testindex/_mapping/user {  "properties": {    "name": {      "type": "text"    }  }}

–给表testtable添加一个字段demo

PUT testindex/_mapping/testtable{  "properties": {    "demo": {      "type": "text"    }  }}

–查看指定表名的表结构
GET /_mapping/testtable

–查看多个表的表结构
GET /_mapping/testtable,user

–查看所有数据库及表的结构
GET /_mapping

–查看指定数据库testindex中所有表的结构
GET /testindex/_mapping
GET /testindex/_settings,_mappings

参考:
集群、分片、节点等概念
http://www.cnblogs.com/dennisit/p/4133131.html

手动指定分片的分布
http://hugoren.iteye.com/blog/2276743

0 0
原创粉丝点击