zoukankan      html  css  js  c++  java
  • elasticsearch REST api

    elasticsearch REST api
    ========================================
    命令模式:<REST Verb> /<Index>/<Type>/<ID>




    插入索引
    ------------
    PUT /customer?pretty

    查询索引列表
    -------------
    GET /_cat/indices?v

    给索引插入文档
    -----------------------
    PUT /customer/external/1?pretty
    {
      "name": "John Doe"
    }

    查询文档
    ---------------
    GET /customer/external/1?pretty

    删除索引
    ------------
    DELETE /customer?pretty


    修改文档
    -------------
    如果index/type/id 相同,就会替换文档
    PUT /customer/external/1?pretty
    {
      "name": "Jane Doe"
    }

    不指定ID插入文档
    ----------------------
    POST /customer/external?pretty
    {
      "name": "Jane Doe"
    }

    更新文档
    ---------------
    POST /customer/external/1/_update?pretty
    {
      "doc": { "name": "Jane Doe", "age": 20 }
    }

    POST /customer/external/1/_update?pretty
    {
      "script" : "ctx._source.age += 5"
    }

    批量操作
    ------------
    POST /customer/external/_bulk?pretty
    {"index":{"_id":"1"}}
    {"name": "John Doe" }
    {"index":{"_id":"2"}}
    {"name": "Jane Doe" }

    POST /customer/external/_bulk?pretty
    {"update":{"_id":"1"}}
    {"doc": { "name": "John Doe becomes Jane Doe" } }
    {"delete":{"_id":"2"}}

    根据索引查询
    -----------------
    GET /bank/_search
    {
      "query": { "match_all": {} },
      "size": 1
    }

    GET /bank/_search
    {
      "query": { "match_all": {} },
      "from": 10,
      "size": 10
    }

    GET /bank/_search
    {
      "query": { "match_all": {} },
      "sort": { "balance": { "order": "desc" } }
    }

    删除旧的日志

    -----------------------

    POST /*/_delete_by_query
    {
    "query": {
        "range": {
            "@timestamp": {
                "lt": "now-10d"
            }
        }
    }
    }

  • 相关阅读:
    从面向对象到SOA
    我对国内软件开发类书籍出版与写作的体会与努力
    MSDN for 2010的那些麻烦事
    金旭亮新作《.NET 4.0面向对象编程漫谈》之序“穿越梦想、起锚远航”
    Silverlight应用程序的本地通讯
    C#中Dictionary的用法
    泛型
    动态规划算法
    C# Timer
    面向对象程序设计寒假作业1
  • 原文地址:https://www.cnblogs.com/zhaojonjon/p/7357344.html
Copyright © 2011-2022 走看看