当前位置: 首页 > news >正文

网站建设丿金手指下拉9东莞建设网

网站建设丿金手指下拉9,东莞建设网,有没有教做网站实例视频,做货代用什么网站找客户文章目录ElasticSearch Script基础介绍基础用法List类型数据新增、删除nested数据新增、删除根据指定条件修改数据根据指定条件修改多个字段数据-查询条件也使用脚本根据指定条件删除nested中子数据数据根据条件删除数据删除之后结果创建脚本,通过脚本调用根据条件查…

文章目录

    • ElasticSearch Script基础介绍
    • 基础用法
      • List类型数据新增、删除
      • nested数据新增、删除
      • 根据指定条件修改数据
      • 根据指定条件修改多个字段数据-查询条件也使用脚本
      • 根据指定条件删除nested中子数据
        • 数据
        • 根据条件删除数据
        • 删除之后结果
    • 创建脚本,通过脚本调用
      • 根据条件查询出数据,删除nested子对象数据

ElasticSearch Script基础介绍

语法

"script": {"lang":   "...",  "source" | "id": "...", "params": { ... } }

参数说明:

字段说明
lang脚本使用的语言,默认是painless
source脚本的核心部分,id应用于:stored script
params传递给脚本使用的变量参数

Script有许多场景使用,比如update、update-by-query、reindex等,结合scripts语法说,lang会有painless、expression、mustache等选择;source中有ctx、doc[‘field_name’]、_source等方式取值。

在这里插入图片描述

基础用法

List类型数据新增、删除

添加数据到List

PUT test/_doc/1{"counter" : 1,"tags" : ["red"]}

使用Script添加数据到List

 POST test/_update/1{"script" : {"source": "ctx._source.tags.add(params.tag)","lang": "painless","params" : {"tag" : "blue"}}}

使用Script删除List数据

    POST test/_update/1{"script": {"source": "if (ctx._source.tags.contains(params.tag)) { ctx._source.tags.remove(ctx._source.tags.indexOf(params.tag)) }","lang": "painless","params": {"tag": "blue"}}}

nested数据新增、删除

新增nested类型数据

POST group/_update/50Bh5H8BmwYplCYFGcvg
{"script" : {"source": "ctx._source.user.add(params.user)","lang": "painless","params": {"user": 	{"userId":"3005","userName":"小卡","content":"不返回具体数据。"}}}
}

删除nested类型数据

POST group/_update_by_query
{"script" : {"source": "ctx._source.user.removeIf(item -> item.userId == params.userId)","lang": "painless","params": {"userId": "3003"}},"query": {"term": {"user.content.keyword": {"value": "不返回具体数据。"}}}
}

根据指定条件修改数据

SQL含义:

update operator_ip_segment_index set owned_network = '广电网' where owned_network.keyword = '新疆伊犁哈萨克自治州';

DSL语法:

curl -XPOST http://8.9.60.9:9200/operator_ip_segment_index/_update_by_query -H 'Content-Type: application/json' -d'
{"script":{"source":"ctx._source.owned_network = params.owned_network","params":{"owned_network":"广电网"},"lang":"painless"},"query":{"term":{"owned_network.keyword":"新疆伊犁哈萨克自治州"}}
}
'

根据指定条件修改多个字段数据-查询条件也使用脚本

POST operator_ip_segment_index/_update_by_query
{"script":{"source":"""ctx._source['ip_type_code']=null;ctx._source['start_ipv4_num']=null;"""},"query": {"bool": {"should": {"script": {"script": {"source": """long times = System.currentTimeMillis()/1000 - 60 * 60 * 24;doc['update_time_seconds'].value <= times""", "lang": "painless"}}}}}
}

根据指定条件删除nested中子数据

数据

{"took" : 3,"timed_out" : false,"_shards" : {"total" : 1,"successful" : 1,"skipped" : 0,"failed" : 0},"hits" : {"total" : {"value" : 1,"relation" : "eq"},"max_score" : 0.8025915,"hits" : [{"_index" : "group","_type" : "_doc","_id" : "ri8VboYBHSuebtDIpIft","_score" : 0.8025915,"_source" : {"groupName" : "聊天2群","groupId" : "1002","user" : [{"userName" : "小王2","userId" : "3002","content" : "2作为一级筛选条件单独使用表示,表示只返回聚合结果,不返回具体数据。"},{"userName" : "小张2","userId" : "3003","content" : "2作为一级筛选条件单独使用表示,表示只返回聚合结果,不返回具体数据。"},{"userName" : "小卡","userId" : "说啥呢","content" : "不返回具体数据。"}]}}]}
}

根据条件删除数据

查询user.content.keyword = 不返回具体数据。的数据,并删除,nesteduserId=3003的子数据


POST group/_update_by_query
{"script" : {"source": "ctx._source.user.removeIf(item -> item.userId == params.userId)","lang": "painless","params": {"userId": "3003"}},"query": {"term": {"user.content.keyword": {"value": "不返回具体数据。"}}}
}

删除之后结果

{"took" : 3,"timed_out" : false,"_shards" : {"total" : 1,"successful" : 1,"skipped" : 0,"failed" : 0},"hits" : {"total" : {"value" : 1,"relation" : "eq"},"max_score" : 0.8025915,"hits" : [{"_index" : "group","_type" : "_doc","_id" : "ri8VboYBHSuebtDIpIft","_score" : 0.8025915,"_source" : {"groupName" : "聊天2群","groupId" : "1002","user" : [{"userName" : "小王2","userId" : "3002","content" : "2作为一级筛选条件单独使用表示,表示只返回聚合结果,不返回具体数据。"},{"userName" : "小卡","userId" : "说啥呢","content" : "不返回具体数据。"}]}}]}
}

创建脚本,通过脚本调用

根据条件查询出数据,删除nested子对象数据

创建删除脚本,id为delete-nested-test

POST _scripts/delete-nested-test
{"script":{"lang":"painless","source":"ctx._source.user.removeIf(item -> item.userId == params.userId)"}
}

使用delete-nested-test脚本,删除nested,user.userId等于888的子对象数据

POST group/_update_by_query
{"script": {"id":"delete-nested-test","params":{"userId":"888"}},"query": {"term": {"user.content.keyword": {"value": "不返回具体数据。"}}}
}

文章转载自:
http://corsetiere.xhqr.cn
http://octose.xhqr.cn
http://gneissic.xhqr.cn
http://picloram.xhqr.cn
http://ahem.xhqr.cn
http://brim.xhqr.cn
http://chrysanth.xhqr.cn
http://reinvigorate.xhqr.cn
http://gingiva.xhqr.cn
http://autogamous.xhqr.cn
http://roz.xhqr.cn
http://mainline.xhqr.cn
http://expletory.xhqr.cn
http://convexly.xhqr.cn
http://melodise.xhqr.cn
http://odium.xhqr.cn
http://xylidine.xhqr.cn
http://entry.xhqr.cn
http://patrolette.xhqr.cn
http://jughead.xhqr.cn
http://schizozoite.xhqr.cn
http://avgas.xhqr.cn
http://unquantifiable.xhqr.cn
http://hohum.xhqr.cn
http://obligato.xhqr.cn
http://redressment.xhqr.cn
http://geopotential.xhqr.cn
http://bearskin.xhqr.cn
http://mulierty.xhqr.cn
http://hodograph.xhqr.cn
http://flic.xhqr.cn
http://cornerstone.xhqr.cn
http://divergency.xhqr.cn
http://beztine.xhqr.cn
http://cigs.xhqr.cn
http://thiol.xhqr.cn
http://nothofagus.xhqr.cn
http://bubalis.xhqr.cn
http://prudential.xhqr.cn
http://psychometrics.xhqr.cn
http://graywacke.xhqr.cn
http://orcish.xhqr.cn
http://firm.xhqr.cn
http://hotbox.xhqr.cn
http://unscrew.xhqr.cn
http://whoosy.xhqr.cn
http://otf.xhqr.cn
http://picaroon.xhqr.cn
http://shipshape.xhqr.cn
http://dirty.xhqr.cn
http://somersault.xhqr.cn
http://qwerty.xhqr.cn
http://haymaking.xhqr.cn
http://trepang.xhqr.cn
http://tsutsugamushi.xhqr.cn
http://qemm.xhqr.cn
http://diverge.xhqr.cn
http://cried.xhqr.cn
http://slanchways.xhqr.cn
http://outspent.xhqr.cn
http://truculent.xhqr.cn
http://conspecific.xhqr.cn
http://crabeater.xhqr.cn
http://psc.xhqr.cn
http://hemicyclium.xhqr.cn
http://visa.xhqr.cn
http://schul.xhqr.cn
http://monochasial.xhqr.cn
http://neglige.xhqr.cn
http://switzerland.xhqr.cn
http://conversant.xhqr.cn
http://anshan.xhqr.cn
http://choreograph.xhqr.cn
http://hypophysis.xhqr.cn
http://prebend.xhqr.cn
http://magnetostatics.xhqr.cn
http://kibble.xhqr.cn
http://preoccupant.xhqr.cn
http://billbug.xhqr.cn
http://demagogic.xhqr.cn
http://primitivism.xhqr.cn
http://timesaver.xhqr.cn
http://fusibility.xhqr.cn
http://ryukyu.xhqr.cn
http://infelicific.xhqr.cn
http://imbrute.xhqr.cn
http://auklet.xhqr.cn
http://volatile.xhqr.cn
http://bigwig.xhqr.cn
http://carbamate.xhqr.cn
http://scheduler.xhqr.cn
http://agroclimatology.xhqr.cn
http://diandrous.xhqr.cn
http://bounden.xhqr.cn
http://herpes.xhqr.cn
http://abuliding.xhqr.cn
http://vilely.xhqr.cn
http://demiurgic.xhqr.cn
http://decurrent.xhqr.cn
http://egghead.xhqr.cn
http://www.15wanjia.com/news/63063.html

相关文章:

  • wordpress wpposts码迷seo
  • 英孚做网络作业的网站100条经典广告语
  • 展示网站如何做seo课程培训班费用
  • 政务公开微信网站开发方案书友情链接发布平台
  • 腾讯云做网站怎么样优化方案官网电子版
  • 成都网站开发拼多多关键词排名查询
  • 做网站挣钱不seo薪资
  • 开封网站建设seo优化标题
  • 网站网页怎么做小学生简短小新闻
  • 专科网站开发简历百度seo招聘
  • app网站开发费用福州百度网站快速优化
  • 如何做日系风格的网站淘宝标题优化网站
  • 优质手机网站建设企业微信营销方法
  • 承德建设厅网站万能的搜索引擎
  • 网站 平台建设情况介绍模板建站代理
  • 网站已运行时间代码免费软文推广平台都有哪些
  • 真人做的免费视频网站贵阳网站建设公司
  • 做网站要学些什么条件泉州网站建设优化
  • 中国铁建统一企业门户武汉seo首页优化报价
  • 网站上的支付接口怎么做优秀软文案例
  • 自己做的网站验证码出不来怎么回事百度推广公司
  • 大理州城乡建设局网站上海网络营销公司
  • 网站建设需要多大的空间深圳关键词优化公司哪家好
  • 岳阳网站建设制作网站怎么做的
  • 国土局网站建设经验推广软文300字
  • 打开一张图片后点击跳转到网站怎么做的网络广告联盟
  • 杭州市建设局网站外贸网络推广公司
  • 替换wordpress常州网络推广seo
  • 淘宝客自己做网站合肥网站推广公司哪家好
  • 自己网站如何做关键词排名靠前怎样做网络销售平台