ES dsl 正则以及统计数量 嵌套对象查询 新增字段数据复制同步

##正则表达式
GET 17-electric-meter-20210407/_search
{
  "query": {
    "regexp": {
      "device_id": "D012103[a-z0-9]+"
    }
  }, 
  "sort": [
    {
      "gather_time": {
        "order": "desc"
      }
    }
  ],
 
  "size":10
}

##正则表达

GET /jv_app_base_spu_test_omni/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "productCode": "JVV1585796047358"
          }
        }
        ,{
          "wildcard": {
             "productName": {
               "wildcard": "*传承系列自动*"
             }
           }
        }
      ]
    }
  },
  "size":10
}

GET 17-electric-meter-20210302/_search
{
  "aggs": {
    "devices": {
      "terms": {
        "field": "device_id",
        "size": 101111
      }
    },
  "per_state_stats": {
      "stats_bucket": {
        "buckets_path": "devices>_count"
      }
    }
  },
  "size": 10
}
#嵌套对象查询

1、

GET /jv_app_sku_test_omni/_search
{
 "track_total_hits": true,
 "query": {
   "nested": {
     "path": "pdtProduct",
     "query": {
       "wildcard": {
         "pdtProduct.productNameCn.keyword": {
           "wildcard": "*性能测试*"
         }
       }
     }
   }
 }
}

2、

GET /jv_app_sku_test_omni/_search
{
  "track_total_hits": true,
  "query": {
    "bool": {
      "must": [
          {
        "nested" : {
          "query" : {
            "term" : {
              "pdtProduct.productCode.keyword" : {
                "value" : "3000400501953087",
                "boost" : 1.0
              }
            }
          },
          "path" : "pdtProduct",
          "ignore_unmapped" : false,
          "score_mode" : "none",
          "boost" : 1.0
        }
      }
      ],
      "adjust_pure_negative": true,
      "boost": 1
    }
  },"size": 50
}

#新增复制字段值

POST /jv_app_base_spu_uat2/_update_by_query?wait_for_completion=false 
{
"script": {
"source": " ctx._source.brandNameAlias = ctx._source.brandName",
"lang": "painless"
}
}

#新增复制replace字段值

POST jv_app_base_spu_uat2/_update_by_query
{
  "script": {
    "lang": "painless",
    "source": "if(ctx._source.brandName!=null){ctx._source.brandNameAlias = ctx._source.brandName.replace('À','A').replace('Â','A').replace('Ä','A').replace('Æ','ae').replace('Ç','C').replace('È','E').replace('É','E').replace('Ê','E').replace('Ë','E').replace('Î','I').replace('Ï','I').replace('Œ','oe').replace('œ','oe').replace('Ô','O').replace('Ö','O').replace('Ù','U').replace('Û','U').replace('Ü','U').replace('à','A').replace('â','A').replace('ä','A').replace('æ','ae').replace('ç','C').replace('è','E').replace('é','E').replace('ê','E').replace('ë','E').replace('€','E').replace('ì','I').replace('í','I').replace('î','I').replace('ï','I').replace('ò','O').replace('ô','O').replace('ö','O').replace('ù','U').replace('û','U').replace('ü','U')}"
  }
}
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值