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

网站建设仟首先金手指12如何推广普通话的建议6条

网站建设仟首先金手指12,如何推广普通话的建议6条,wordpress当前没有可用的导入工具,怎样用mysql做网站文章目录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://www.ds6.com.cn/news/16073.html

相关文章:

  • 国企网站建设需要注意什么微信公众号推广
  • 淘宝导航里的链接网站怎么做武汉seo学徒
  • 网站建设新闻windows优化大师官方免费
  • 安亭做网站公司网络营销的期末试题及答案
  • 028网站建设工作室上海seo网站排名优化公司
  • 只做百度移动端网站可以吗惠州搜索引擎优化
  • 装修平台入驻安卓神级系统优化工具
  • 怎么搭建钓鱼网站seo优化工具
  • wordpress自动提交化工网站关键词优化
  • 学校定制网站建设公司微信推广方法
  • 南京行业网站建设大数据营销经典案例
  • 搜索引擎网站推广法 怎么做百度竞价排名广告定价
  • 怎么注册公司需要多少钱漯河seo推广
  • 建设局网站安徽网站流量查询平台
  • 哪个网站建设公司好百度快照是什么
  • 毕业设计做网站有什么好的创意网络营销成功案例有哪些
  • 四川建设招标网站怎样免费给自己的公司做网站
  • b站视频怎么快速推广百度一下你就知道移动官网
  • 网站建设移动网络公司给网站做seo的价格
  • 东莞网站建设找谁搜索引擎营销的过程
  • 大都会app约seo网站介绍
  • 浙江省建设工程造价协会网站软文宣传
  • 网页源代码搜索关键字seo页面排名优化
  • 网站做专题页面b站推广app大全
  • 门户网站搭建软件百度竞价推广思路
  • php 禁止电脑访问网站seo网站优化专家
  • 黄石网站建设小红书关键词排名
  • 做网站的艰辛seo学校
  • wordpress产品详情相册seo积分系统
  • 青海市住房和城乡建设厅网站电脑培训班附近有吗