Skip to main content
stephane_davy
Gold ⭐️
July 2, 2020
Solved

Apache Nifi: filter recordpath on boolean fields

Hello,

 

I have a piece of JSON on which I want to apply an updateRecord processor using some filter capabilities. My JSON looks like this:

 

 

   "status": [
{
"code": "InProgress",
"isCurrentStatus": false,
"startDateTime": "2020-03-05T20:45:00Z"
},
{
"code": "Pending",
"isCurrentStatus": true,
"startDateTime": "2020-03-05T21:20:00Z"
}
],

 

 

 

And my RecordPath expression is the following:

 

 

 

/status[0..-1][./isCurrentStatus = true]/code

 

 

This expression doesn't work and I have an error in my logs file stating about incorrect syntax:  Unexpected token ']' at line 1

 

If I put the following syntax:

 

 

/status[0..-1][./isCurrentStatus = "true"]/code

 

 

it doesn't give anymore error, but of course the filter doesn't work. So, I have the feeling that recordPath filter doesn't support the use of boolean values.

 

My Nifi is Nifi 1.9.0 coming with HDF 3.4.

 

Any idea?

 

Thanks a lot,

 

Stéphane

 

stephane_davy
Gold ⭐️
July 10, 2020

Answer to myself: I solved the problem by converting this boolean to string using Jolt:

{
"operation": "modify-overwrite-beta",
"spec": {
"status": {
"*": {
"isCurrentStatus": "=toString"
}
}
}
}

 

2 replies

stephane_davy
stephane_davyAuthorAnswer
Gold ⭐️
July 10, 2020

Answer to myself: I solved the problem by converting this boolean to string using Jolt:

{
"operation": "modify-overwrite-beta",
"spec": {
"status": {
"*": {
"isCurrentStatus": "=toString"
}
}
}
}

 

Translate
cjervis
Community Manager
Community Manager
July 10, 2020

I'm happy to see you resolved your issue. Please mark the appropriate reply as the solution, as it will make it easier for others to find the answer in the future. 

 

Screen Shot 2019-08-06 at 1.54.47 PM.pngmark as solution button

 

 

Translate
Keep the questions coming