• 更新数据


    POST zeppelin/examples/AV6nU7M9HTZ4wJwaOOJj/_update
    {
        "name": "新闻主题分布",
        "url": "notebook/2CTNKD25S"
    }

    PUT test/type1/1{
        "counter" : 1,
        "tags" : ["red"]
    }
    增量某一字段
    POST yuantest/type1/1/_update
    {
        "script" : {
            "inline": "ctx._source.counter += count",
            "lang": "painless",
            "params" : {
                "count" : 4
            }
        }
    }
     
    增加列表属性字段
    POST yuantest/type1/1/_update
    {
        "script" : {
            "inline": "ctx._source.tags.add(params.tag)",
            "lang": "painless",
            "params" : {
                "tag" : "blue"
            }
        }
    }
     
    增加新字段
    POST yuantest/type1/1/_update
    {
        "script" : "ctx._source.new_field = "value_of_new_field""
    }
     
    POST yuantest/type1/1/_update
    {
        "doc" : {
            "name" : "new_name"
        }
    }
     
    删除字段
    POST yuantest/type1/1/_update
    {
        "script" : "ctx._source.remove("new_field")"
    }
     
    如果tag字段中有red字段,则删除该记录(不会循环做,只会删除第一条符合条件的数据)
    POST yuantest/type1/1/_update
    {
        "script" : {
            "inline": "if (ctx._source.tags.contains(params.tag)) { ctx.op = "delete" } else { ctx.op = "none" }",
            "lang": "painless",
            "params" : {
                "tag" : "red"
            }
        }
    }

    有记录执行script,没记录走upsert
    POST yuantest/type1/1/_update
    {
        "script" : {
            "inline": "ctx._source.counter += params.count",
            "lang": "painless",
            "params" : {
                "count" : 4
            }
        },
        "upsert" : {
            "counter" : 1
        }
    }
     
    若没有id为1的记录,则将doc的内容作为记录
    POST yuantest/type1/1/_update
    {
        "doc" : {
            "name" : "new_name"
        },
        "doc_as_upsert" : true
    }
  • 相关阅读:
    hdu 5446 Unknown Treasure lucas和CRT
    Hdu 5444 Elven Postman dfs
    hdu 5443 The Water Problem 线段树
    hdu 5442 Favorite Donut 后缀数组
    hdu 5441 Travel 离线带权并查集
    hdu 5438 Ponds 拓扑排序
    hdu 5437 Alisha’s Party 优先队列
    HDU 5433 Xiao Ming climbing dp
    hdu 5432 Pyramid Split 二分
    Codeforces Round #319 (Div. 1) B. Invariance of Tree 构造
  • 原文地址:https://www.cnblogs.com/helloworld0604/p/9510201.html
Copyright © 2020-2023  润新知