zoukankan      html  css  js  c++  java
  • ES入门REST API

    在ES中存在4种数据对象,分别是 index  ,  type ,  document  , field .   其跟我们熟悉的关系型数据库得二维表得对应关系为:

    index -> table表 ,  document -> row行 , field -> column列, type无对应得关系,它为index得一种逻辑分类.

    ES使用 index 为单元来组织数据(document),一个index可以有一个或者多个type,document为最基础得数据单元,

    document中得信息存储在字段(field)中.

    下面梳理出几个入门级得简单得curl简单使用。

    1、查看集群情况网页地址: 

    http://master_node_ip:9100/

    2、查看集群得健康状态:

    curl -XGET 'localhost:9200/_cat/health?v'

    3、查看集群的节点数目和主节点等信息

    curl -XGET localhost:9200/_cat/nodes?v'

    4、新建一个索引

    curl -XPUT 'localhost:9200/jim/?pretty'

    5、查看索引得setting及mapping

    curl -XGET 'localhost:9200/jim/_settings?pretty'
    curl -XGET 'localhost:9200/jim/_mappings?pretty'

    6、添加document

    curl -XPUT 'localhost:9200/jim/firstme/1?pretty' -d '{
        "firstname":        "LoadL",
        "lastname":         "Lee",
        "age":              27,
        "on_line_date":    "2018-11-11",
        "hometown":         "DB",
        "nowlive":          "BeiJing",
        "married":          false,
        "about":            "I love Beijing Opera"
    }'

    7、查看是否存在某个document

    curl -i -XHEAD 'localhost:9200/jim/firstme/1'
    返回200为存在,返回404为不存在

    8、获取一个document

    curl -XGET 'localhost:9200/jim/firstme/1?pretty'
    "_source"字段中存储的是Document内部的数据

    9、更新document

    curl -XPUT 'localhost:9200/jim/firstme/1?pretty' -d '{
        "firstname":        "LoadL",
        "lastname":         "Lee",
        "age":              27,
        "on_line_date":    "2018-11-11",
        "hometown":         "HeiLongJiang",
        "nowlive":          "BeiJing",
        "married":          false,
        "about":            "I love Beijing Opera"
    }'
    更新完成后,该document得version会加1

    10、删除document

    curl -XDELETE 'localhost:9200/jim/firstme/1?pretty'

    11、删除index

    curl -XDELETE 'localhost:9200/jim/?pretty'
  • 相关阅读:
    Python-发送邮件
    Python基础-类的继承
    Python基础-列表推导式
    三、Linux下mysql的完整安装
    二、linux下apache2.2.11+php5.6.3的环境配置
    linux下编译安装php各种报错大集合
    一、linux下nginx1.7.8+php5.6.3的环境配置
    linux ./configure 的参数详解
    div随窗口变化设置高度
    在地图上增加标注点并为每个点增加各自的信息窗口
  • 原文地址:https://www.cnblogs.com/loadL/p/simple_es_curl.html
Copyright © 2011-2022 走看看