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"}}
    '

     

    • 执行高级搜索操作,如分页,排序,过滤,脚本,聚合等等
  • 相关阅读:
    浙江省新一代多普勒天气雷达系统
    删除目录下的所有文件及子文件夹
    在南京14所测试出厂雷达(转)
    c++实现aes加密算法,对字符串进行加密
    自已在别人基础上封装的AES数法 C++
    IOS发布问题
    GameCenter 使用指南
    [iOS]AES加密在iOS上面的实现
    【iOS开发必收藏】详解iOS应用程序内使用IAP/StoreKit付费、沙盒(SandBox)测试、创建测试账号流程!【2012625日更新iap恢复详解】
    基于cocos2dx引擎的游戏框架设计
  • 原文地址:https://www.cnblogs.com/zhxdxf/p/8308568.html
Copyright © 2011-2022 走看看