11-18-2020 08:33 PM
Hello,
How do you conditionally remove (or add) a field to a document?
E.g., I have a mapper:
Expression → Target Path
20 → $field1
10 → $field2
‘’ → $field3
null → $field4
So I now have:
[
{
‘field1’:20
,‘field2’:10
,‘field3’:‘’
,‘field4’:null
}
]
Now for example in pseudo code:
if ( $field2 > 5 ) { delete($.field2) }
if ( $field3 == ‘’) {delete($.field3) }
if ( $field4 == null ) { delete($.field4) }
So now it looks like:
[
{
‘field1’:20
}
]
How can I do that? Note: I can achieve this with a JSON Generator using Apache Velocity, but I’m hoping there is a way to do this using something like a Mapper.
It would also be OK to do this in the opposite direction, e.g.,
if ( $input <= 4 ) { create($.field2, $input) }
Let me know if you have any questions,
Thanks!
Ish
11-19-2020 12:40 PM
Sorry, Aha is a mystery to us all. 🙂 Just reference the ticket in your communications with your CS or support rep.