栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

ES详解 - 索引:索引管理详解

ES详解 - 索引:索引管理详解

索引管理

索引管理的引入索引的格式索引管理操作

创建索引修改索引打开/关闭索引删除索引查看索引

索引管理的引入
PUT /customer/_doc/1
{
  "name": "John Doe"
}

而这个index实际上已经自动创建了它里面的字段(name)的类型。我们不妨看下它自动创建的mapping:

{
  "mappings": {
    "_doc": {
      "properties": {
        "name": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        }
      }
    }
  }
}

第一个禁止自动创建索引,第二个是手动创建索引。

禁止自动创建索引
vi config/elasticsearch.yml

action.auto_create_index: false
索引的格式

在请求体里面传入设置或类型映射,如下所示:

PUT /my_index
{
    "settings": { ... any settings ... },
    "mappings": {
        "properties": { ... any properties ... }
    }
}

settings: 用来设置分片,副本等配置信息mappings: 字段映射,类型等 索引管理操作 创建索引

PUT /test-index-users
{
  "settings": {
		"number_of_shards": 1,
		"number_of_replicas": 1
	},
  "mappings": {
    "properties": {
      "name": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "age": {
        "type": "long"
      },
      "remarks": {
        "type": "text"
      }
    }
  }
}
修改索引

修改副本为0

PUT /test-index-users/_settings
{
  "settings": {
    "number_of_replicas": 0
  }
}
打开/关闭索引

关闭索引

一旦索引被关闭,那么这个索引只能显示元数据信息,不能够进行读写操作。
POST /test-index/_close

开启索引

POST /test-index/_open

删除索引

DELETE /test-index

查看索引

查看mapping

GET /index/_mapping

查看setting

GET /index/_setting

查看所有

GET /index

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/720382.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号