问题
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 == \"\""
}
}
}
回答1:
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);
}
"""
}
}
回答2:
You can give, comma separate field names, or try with *(not sure whether its support, I am trying this), but comma(,) separate works for sure, as shown in the official doc
https://www.elastic.co/guide/en/elasticsearch/reference/master/remove-processor.html
{
"remove": {
"field": ["user_agent", "url"]
}
}
来源:https://stackoverflow.com/questions/64751852/elastisearch-how-to-process-all-fields-in-document-while-using-pipeline-proces