本文介绍了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
发布评论