ElasticSearch 6.x 学习笔记:6.索引

2022-05-06 19:08:24 浏览数 (1)

6.1 创建索引

(1)简单方式

代码语言:javascript复制
PUT test
代码语言:javascript复制
{
  "acknowledged": true,
  "shards_acknowledged": true,
  "index": "test"
}

(2)索引名不能包含大些字母

代码语言:javascript复制
PUT Test

(3)重复创建

代码语言:javascript复制
PUT test

(4)指定参数

代码语言:javascript复制
PUT blog
{
  "settings": {
    "number_of_shards": 3,
    "number_of_replicas": 1
  } 
}
代码语言:javascript复制
{
  "acknowledged": true,
  "shards_acknowledged": true,
  "index": "blog"
}

6.2 查看索引

(1)查看指定索引的配置信息

代码语言:javascript复制
GET blog/_settings
代码语言:javascript复制
{
  "blog": {
    "settings": {
      "index": {
        "creation_date": "1515458969949",
        "number_of_shards": "3",
        "number_of_replicas": "1",
        "uuid": "A7pKNO7bTgucu1uNgmXlQg",
        "version": {
          "created": "5060399" },
        "provided_name": "blog"
      }
    }
  }
}

(2)查看多个索引

代码语言:javascript复制
GET test,blog/_settings
代码语言:javascript复制
{
  "test": {
    "settings": {
      "index": {
        "creation_date": "1515460501267",
        "number_of_shards": "5",
        "number_of_replicas": "1",
        "uuid": "FfVJ9w9bSxqyqvh7r1UL7w",
        "version": {
          "created": "5060399" },
        "provided_name": "test"
      }
    }
  },
  "blog": {
    "settings": {
      "index": {
        "creation_date": "1515459619703",
        "number_of_shards": "3",
        "number_of_replicas": "1",
        "uuid": "6x9RQQ5KRoStK57T88VhmA",
        "version": {
          "created": "5060399" },
        "provided_name": "blog"
      }
    }
  }
}

6.3 删除索引

代码语言:javascript复制
DELETE test
代码语言:javascript复制
{
  "acknowledged": true
}

6.4 索引的打开与关闭

(1)关闭索引

代码语言:javascript复制
POST blog/_close
代码语言:javascript复制
{
  "acknowledged": true
}

(2)尝试插入数据

代码语言:javascript复制
PUT blog/article/1
{
  "title":"test title"  
}

index_closed_exception

(3)重新打开索引

代码语言:javascript复制
POST blog/_open

0 人点赞