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


原文: https://blog.csdn.net/chengyuqiang/article/details/79009270

6.1 创建索引

(1)简单方式

PUT test
{
  "acknowledged": true,
  "shards_acknowledged": true,
  "index": "test"
}

ElasticSearch 6.x 学习笔记:6.索引
(2)索引名不能包含大些字母

PUT Test

ElasticSearch 6.x 学习笔记:6.索引
(3)重复创建

PUT Test

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

(4)指定参数

PUT blog
{
  "settings": {
    "number_of_shards": 3,
    "number_of_replicas": 1
  } 
}
{
  "acknowledged": true,
  "shards_acknowledged": true,
  "index": "blog"
}

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

6.2 查看索引

GET blog/_settings
{
  "blog": {
    "settings": {
      "index": {
        "creation_date": "1515458969949",
        "number_of_shards": "3",
        "number_of_replicas": "1",
        "uuid": "A7pKNO7bTgucu1uNgmXlQg",
        "version": {
          "created": "5060399"
        },
        "provided_name": "blog"
      }
    }
  }
}

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

(2)查看多个索引

GET test,blog/_settings
{
  "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"
      }
    }
  }
}

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

6.3 删除索引

DELETE test
{
  "acknowledged": true
}

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

6.4 索引的打开与关闭

(1)关闭索引

POST blog/_close
{
  "acknowledged": true
}

ElasticSearch 6.x 学习笔记:6.索引
(2)尝试插入数据

PUT blog/article/1
{
  "title":"test title"  
}

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

(3)重新打开索引

POST blog/_open

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