美文网首页
ElasticSearch学习笔记5--索引

ElasticSearch学习笔记5--索引

作者: 荆辰曦 | 来源:发表于2018-09-05 14:52 被阅读0次

    5.1 创建索引

    (1)简单方式

    PUT test
    

    响应

    {
      "acknowledged": true,
      "shards_acknowledged": true,
      "index": "test"
    }
    
    20180106185937040.png

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

    PUT Test
    
    20180106185937040.png

    (3)重复创建

    PUT test
    
    20180106185937040.png

    (4)指定参数

    PUT blog
    {
      "settings": {
        "number_of_shards": 3,
        "number_of_replicas": 1
      } 
    }
    

    响应

    {
      "acknowledged": true,
      "shards_acknowledged": true,
      "index": "blog"
    }
    
    20180106185937040.png

    5.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"
          }
        }
      }
    }
    
    20180106185937040.png

    (2)查看多个索引

    GET test,blog/_settings
    
    查看多个索引

    5.3 删除索引

    DELETE test
    

    响应

    {
      "acknowledged": true
    }
    

    5.4 索引的打开与关闭

    (1)关闭索引

    POST blog/_close
    
    关闭索引

    (2)尝试插入数据

    PUT blog/article/1
    {
      "title":"test title"  
    }
    
    尝试插入数据

    (3)重新打开索引

    POST blog/_open
    
    重新打开索引

    相关文章

      网友评论

          本文标题:ElasticSearch学习笔记5--索引

          本文链接:https://www.haomeiwen.com/subject/lmeawftx.html