您的位置 首页 elasticsearch

es 索引

1-索引管理-查看

1.查看所有索引
GET http://10.0.0.111:19200/_cat/indices?v
2.查看单个索引的详细信息
GET http://10.0.0.111:19200/baimei

2-索引管理-创建

1.直接创建索引
PUT  http://10.0.0.111:19200/baimei
2.指定分片创建索引
PUT  http://10.0.0.111:19200/baimei4
{
    "settings": {
        "index": {
            "number_of_shards": "3"
    
        }
    }
}

 

3.指定分片和副本创建索引

PUT http://10.0.0.111:19200/baimei3

{
    "settings": {
        "index": {
            "number_of_shards": "3",
            "number_of_replicas": "0"
        }
    }
}

索引管理-修改

1.修改索引的副本数量
PUT http://10.0.0.101:19200/baimeidashu-linux88/_settings
{
    "number_of_replicas": "2"
}
温馨提示:
不允许动态修改分片的数量。

索引管理-删除

1.通过es-head删除
2.通过curl删除
curl -X DELETE 10.0.0.111:19200/baimeidashu-linux88
3.postman删除
删除单个索引
DELETE
http://10.0.0.111:19200/baimei3

基于通配符删除索引:
DELETE
http://10.0.0.111:19200/baimei*

关闭索引:
(索引关闭后,无法进行读写操作,但数据不会被删除)
POST
http://10.0.0.111:19200/baimei/_close

打开索引:(创建的索引默认就是打开状态的)
POST
http://10.0.0.111:19200/baimei/_open

温馨提示:
生产环境中,建议将删除动作改为关闭索引动作,若关闭索引1周后,没有被使用,则进行删除。

索引别名:

1.查看所有索引的别名
GET
http://10.0.0.111:19200/_aliases

 

2.为索引添加别名
POST
http://10.0.0.111:19200/_aliases

 

{
    "actions": [
        {
            "add": {
                "index": "baimei",
                "alias": "Linux容器运维工程师"
            }
        },
        {
            "add": {
                "index": "baimei4",
                "alias": "DBA"
            }
        },
        {
            "add": {
                "index": "baimei4",
                "alias": "BBQ"
            }
        }
       
    ]
}

 

3.删除别名
POST
http://10.0.0.111:19200/_aliases

 

{
    "actions": [
        {
            "remove": {
                "index": "baimei",
                "alias": "Linux容器运维工程师"
            }
        },
        {
            "remove": {
                "index": "baimei4",
                "alias": "DBA"
            }
        },
        {
            "remove": {
                "index": "baimei4",
                "alias": "BBQ"
            }
        }
       
    ]
}

 

4.修改别名
POST
http://10.0.0.111:19200/_aliases

 

{
    "actions": [
        {
            "remove": {
                "index": "baimei",
                "alias": "Linux容器运维工程师"
            }
        },
        {
            "add": {
                "index": "baimei",
                "alias": "dba"
            }
        }
    ]
}

 

索引的其他操作:
https://www.elastic.co/guide/en/elasticsearch/reference/current/indices.html
索引:
- 分片:
- 数据: document(文档),对应的是一个JSON格式对象数据类型。

欢迎来撩 : 汇总all

白眉大叔

关于白眉大叔linux云计算: 白眉大叔

热门文章