1. GET usernested/_search
  2. {
  3. "query": {
  4. "nested": {
  5. "path": "tags",
  6. "query": {
  7. "bool": {
  8. "must": [
  9. {
  10. "term": {
  11. "tags.brandid": "93a8296c-5b64-49ea-bd92-b19192def2e9"
  12. }
  13. },
  14. {
  15. "term": {
  16. "tags.site": "163"
  17. }
  18. }
  19. ]
  20. }
  21. }
  22. }
  23. }
  24. }
  25.  
  26. //按照条件新建一个index 作为测试数据使用
  27. POST _reindex
  28. {
  29. "source": {
  30. "index": "usernested",
  31. "query": {
  32. "nested": {
  33. "path": "tags",
  34. "query": {
  35. "bool": {
  36. "must": [
  37. {
  38. "term": {
  39. "tags.brand": "c55fd643-1333-4647-b898-fb3e5e4e6d67"
  40. }
  41. },
  42. {
  43. "term": {
  44. "tags.site": "163"
  45. }
  46. }
  47. ]
  48. }
  49. }
  50. }
  51. }
  52. },
  53. "dest": {
  54. "index": "new_usernested"
  55. }
  56. }
  57.  
  58. //查询
  59. GET new_usernested/_search
  60. {
  61. "query": {
  62. "nested": {
  63. "path": "tags",
  64. "query": {
  65. "bool": {
  66. "must": [
  67. {
  68. "term": {
  69. "tags.brand": "c55fd643-1333-4647-b898-fb3e5e4e6d67"
  70. }
  71. },
  72. {
  73. "term": {
  74. "tags.site": "163"
  75. }
  76. }
  77. ]
  78. }
  79. }
  80. }
  81. }
  82. }
  83.  
  84. //根据条件更新一个 nested的文档
  85. GET usernested/_update_by_query
  86. {
  87. "query": {
  88. "nested": {
  89. "path": "tags",
  90. "query": {
  91. "bool": {
  92. "must": [
  93. {
  94. "term": {
  95. "tags.brand": "c55fd643-1333-4647-b898-fb3e5e4e6d67"
  96. }
  97. },
  98. {
  99. "term": {
  100. "tags.site": "163"
  101. }
  102. }
  103. ]
  104. }
  105. }
  106. }
  107. },
  108. "script": {
  109. "inline": "for(e in ctx._source.tags){e.brand = 'test2';}" //更新nested字段
    //"inline":"ctx._source.userid = 'testid'" //更新普通字段
  110. }
  111. }

ElasticSearh更新nested字段(Array数组)。怎么根据查询条件(query)复制一个(index)到新的Index how to update by query a nested fields data for elasticsearch的更多相关文章

  1. find、findIndex、indexOf、lastIndex、includes 数组五种查询条件方法介绍

    find() 方法返回数组中满足提供的测试函数的第一个元素的值. 语法: arr.find(callback[, thisArg]) findIndex()方法返回数组中满足提供的测试函数的第一个元素 ...

  2. thinkphp 多个字段的不同关系的查询条件实现 .

    tp的$map不同条件默认是 and ,如果要用or<><><><>如下 例如查询Stu表中年龄大于18,或者身高低于180cm的男性(1为男性),(例 ...

  3. PostgreSQL Array 数组类型与 FreeSql 打出一套【组合拳】

    前言 PostgreSQL 是世界公认的功能最强大的开源数据库,除了基础数据类型 int4/int8/varchar/numeric/timestamp 等数据类型,还支持 int4[]/int8[] ...

  4. JavaScript的json和Array及Array数组的使用方法

    1.关于json JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式.它基于ECMAScript的一个子集.也可以称为数据集和数组类似,能够存数据! //Ar ...

  5. JS中Array数组的三大属性用法

    原文:JS中Array数组的三大属性用法 Array数组主要有3大属性,它们分别是length属性.prototype属性和constructor属性. JS操作Array数组的方法及属性 本文总结了 ...

  6. MongoDB的批量查询条件进行批量更新数据

    今天遇到这样一个场景:在Java中批量更新MongoDB数据,不过每次更新的条件有不一样,那如何有效地进行更新操作呢? 刚开始的时候,我是想到循环批量更新操作,即每一种查询条件进行一次批量更新过程,这 ...

  7. for 循环 和 Array 数组对象

    博客地址:https://ainyi.com/12 for 循环 和 Array 数组对象方法 for for-in for-of forEach效率比较 - 四种循环,遍历长度为 1000000 的 ...

  8. Javascript中的Array(数组) 、{}(映射) 与JSON解析

    做网页总会使用javascript,使用javascript总会使用JSON.最近用到一下,就写写. 下面是总结: 1.将javascript中的Array和{}转化为json字符串可以使用json2 ...

  9. List集合与Array数组之间的互相转换

    1.数组转换成List集合 采用java中集合自带的asList()方法就可以完成转换了 String[] array = new String[] {"zhu", "w ...

随机推荐

  1. Container [pid=6263,containerID=container_1494900155967_0001_02_000001] is running beyond virtual memory limits

    以Spark-Client模式运行,Spark-Submit时出现了下面的错误: User: hadoop Name: Spark Pi Application Type: SPARK Applica ...

  2. RN组件备忘录

    1:ActivityIndicator:圆形的loading提示符号. 2:Button:按钮 3:FlatList:高性能列表组件,支持下拉刷新. 4:Image:图片组件,能显示 网络图片.静态资 ...

  3. Ajax实现文件上传的临时垃圾文件回收策略

    转载请注明原文出处:http://www.cnblogs.com/ygj0930/p/6126240.html 在我们web开发过程中,一个很重要的技术就是Ajax(异步传输).Ajax通过把数据从网 ...

  4. CentOS 7 安装php5.6,Nginx,Memcached环境及配置

    安装php5.6版本以后不再需要安装Zend Guard,而是用yum命令安装php-opcache及php-pecl-apcu就可以有效的提高php执行速度. 1. 配置yum源 事先确认yum源的 ...

  5. SUMIF

    SUMIF(range,criteria,sum_range) Range:条件区域,用于条件判断的单元格区域. Criteria:求和条件,由数字.逻辑表达式等组成的判定条件.criteria 参数 ...

  6. 安装win和xp双系统 若干问题

    装了winxp和linux双系统,后先在winxp下手动格式化了linux系统,后启动时提示grub错误,重新分区后系统也 2010-09-17 21:07 [清风剑] | 分类:Linux | 浏览 ...

  7. 重装wordpress

    1.删除wordpress: https://blog.csdn.net/yeqinghanwu/article/details/77916912 2.uninstall lnmp 3.安装lnmp ...

  8. App 开发步骤

    在 iOS 开发中,写一个 App 很容易,但是要写好一个 App,确是要下另一番功夫.首先,我们来看一个 App 的开发要求: 写一个 App,显示出 Spotify 上 Lady Gaga 相关的 ...

  9. 【LeetCode】221. Maximal Square

    Maximal Square Given a 2D binary matrix filled with 0's and 1's, find the largest square containing ...

  10. 【LeetCode】174. Dungeon Game

    Dungeon Game The demons had captured the princess (P) and imprisoned her in the bottom-right corner ...