您的位置:首页 > 其它

Elasticsearch6.2.2说明文档--index操作

2018-03-13 13:51 190 查看
环境:       Elasticsearch: 6.2.2       Kibana: 6.2.2       os: centos 7 原文地址:https://www.elastic.co/guide/en/elasticsearch/reference/current/_index_and_query_a_document.html 原文地址:https://www.elastic.co/guide/en/elasticsearch/reference/current/_list_all_indices.html
1、查看所有index,即查看indices    命令:GET /_cat/indices?v    结果:           

   结果中包含每一个index的健康状态,名称,以及一些存储信息。 2、创建index      命令:PUT /customer?pretty       该命令是创建一个名为customer的index,后面的pretty参数只是为了得到一个美化后的响应结果
      使用 GET /_cat/indices?v 查看刚才创建的index,我们可以看到主分区为5个,副分区为1个,这些都是ES默认值,如果此时你的单节点ES,你会发现此时index的状态为yellow,参考状态说明,我们可以知道,是因为单节点不符合HA,所以为黄色。3、插入document     命令:
    PUT /customer/_doc/1?pretty
    {
      "name": "John Doe"
    }
    结果:

    


    另外ES在插入document的时候不需要提前创建index,如果不存在该index,则会自动创建然后插入。
4、删除index    命令:DELETE /customer   然后 GET /_cat/indices?v   则再没有名字为customer的index  总结:有上面示例中可以看出,再ES中数据处理的模式为:<REST Verb> /<Index>/<Type>/<ID>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: