赞
踩
现es日志中需要按照字段为 "microName"="数智可视化平台" 的数据都要更新历史字段serverTag、preview的值,网上博客看了一大堆没有正常的。
elasticsearch7 、postman
按条件更新单个字段
- POST 192.168.XX.XX:9200/esbizlog/_update_by_query
-
- {
- "query": {
- "bool": {
- "must": [
- {
- "match_phrase": {
- "microName": "数智可视化平台"
- }
- }
- ]
- }
- },
- "script":{
- "inline": "ctx._source['preview']='true'"
- }
- }
按条件更新多个字段
- POST 192.168.XX.XX:9200/esbizlog/_update_by_query
-
- {
- "query": {
- "bool": {
- "must": [
- {
- "match_phrase": {
- "microName": "数智可视化平台"
- }
- }
- ]
- }
- },
- "script":{
- "inline": "ctx._source['preview']='true'; ctx._source['serverTag']='bi'"
- }
- }
!!完美通过
案例验证:
网上博客大多数都是如下案例:
然后提示如下错误
- {
- "error": {
- "root_cause": [
- {
- "type": "parse_exception",
- "reason": "expected one of [inline], [file] or [stored] fields, but found none"
- }
- ],
- "type": "parse_exception",
- "reason": "expected one of [inline], [file] or [stored] fields, but found none"
- },
- "status": 400
- }
原因就是:在script中source和inline的用法没有搞清楚!!!
chatGpt看一下两者有什么区别
不得不说 chartGpt真牛逼
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。