zoukankan      html  css  js  c++  java
  • ES 集群管理及基本操作

    通过REST API管理集群

    • 检查群集,节点和索引运行状况,状态和统计信息
    查看集群健康状况 [root@lv120 elasticsearch]# curl -XGET 'http://10.45.157.120/_cat/health?v'
    查看节点 [root@lv120 elasticsearch]# curl -XGET 'http://10.45.157.120:9200/_cat/nodes?v'
    查看所有索引 [root@lv120 elasticsearch]# curl -XGET 'http://10.45.157.120:9200/_cat/indices?v'
    • 管理群集,节点和索引数据和元数据
    • 对索引执行CRUD(创建,读取,更新和删除)和搜索操作
    创建索引 curl -XPUT 'localhost:9200/customer/doc/1?pretty&pretty' -H 'Content-Type: application/json' -d'
    {
    "name": "John Doe"
    }‘
    post插入  没有指定id  ,会自动生成一个id curl -XPOST 'localhost:9200/customer/doc?pretty&pretty' -H 'Content-Type: application/json' -d'
    {
    "name": "Jane Doe"
    }
    '
    读取 [curl -XGET 'localhost:9200/customer/doc/1?pretty&pretty'

    删除 curl -XDELETE 'localhost:9200/customer?pretty&pretty'
    更新文档-修改一个field值 curl -XPOST 'localhost:9200/customer/doc/1/_update?pretty&pretty' -H 'Content-Type: application/json' -d'
    {
    "doc": { "name": "Jane Doe" }
    }
    '
     更新文档-添加一个field

    curl -XPOST 'localhost:9200/customer/doc/1/_update?pretty&pretty' -H 'Content-Type: application/json' -d'
    {
    "doc": { "name": "Jane Doe", "age": 20 }
    }
    '

     更新文档-脚本操作field值(当前文档age+5)  

    curl -XPOST 'localhost:9200/customer/doc/1/_update?pretty&pretty' -H 'Content-Type: application/json' -d'
    {
    "script" : "ctx._source.age += 5"
    }
    '

    批量操作-新增

    curl -XPOST 'localhost:9200/customer/doc/_bulk?pretty&pretty' -H 'Content-Type: application/json' -d'
    {"index":{"_id":"1"}}
    {"name": "John Doe" }
    {"index":{"_id":"2"}}
    {"name": "Jane Doe" }
    '

    批量操作-删除修改

    (批量操作中一个失败,后面会继续执行,

    返回每个操作的执行情况)

    curl -XPOST 'localhost:9200/customer/doc/_bulk?pretty&pretty' -H 'Content-Type: application/json' -d'
    {"update":{"_id":"1"}}
    {"doc": { "name": "John Doe becomes Jane Doe" } }
    {"delete":{"_id":"2"}}
    '

     

    • 执行高级搜索操作,如分页,排序,过滤,脚本,聚合等等
  • 相关阅读:
    arcgis建立拓扑分析(检验矢量图)
    矢量图面层和线层相交得到相交后的线层文件(gis相交)
    关于处理注册表权限无法修改的问题(无法打开主键或注册表项unknown)
    my.cnf配置文件
    keepalived联动mysql
    安装客户端连接软件(zabbix_agentd-filebeat-flume)
    zabbix短信配置说明
    zabbix监控工具添加网络设备Ping
    新买了硬盘,让Linux系统识别硬盘nfs---->改成xfs
    vnc软件使用
  • 原文地址:https://www.cnblogs.com/zhxdxf/p/8308568.html
Copyright © 2011-2022 走看看