Elastisearch

编程入门 行业动态 更新时间:2024-10-09 21:28:26
本文介绍了Elastisearch-如何在使用管道处理器时处理文档中的所有字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用以下处理器,但是我想将其应用于所有字段.因此,我需要在字段"中添加所有字段,还是有其他方法可以做到这一点.

I am using below processor, but I want to apply it on all fields. So will I need to add all fields in 'field' or is there any other way to do it.

"description": "my pipeline that remvoves empty string and null strings", "processors": [ { "remove": { "field": "my_field", "ignore_missing": true, "if": "ctx.my_field == \"null\" || ctx.my_field == \"\"" } } }

推荐答案

删除处理器不允许您使用通配符 * 来检查所有字段.相反,您可以选择 script 处理器并以通用方式自己执行:

The remove processor doesn't allow you to use wildcard * for checking all fields. Instead you can pick the script processor and do it yourself in a generic way:

{ "script": { "source": """ // find all fields that contain an empty string or null def remove = ctx.keySet().stream() .filter(field -> ctx[field] == "null" || ctx[field] == "") .collect(Collectors.toList()); // remove them in one go for (field in remove) { ctx.remove(field); } """ } }

更多推荐

Elastisearch

本文发布于:2023-11-27 21:40:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639695.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Elastisearch

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!