Support Questions

Find answers, ask questions, and share your expertise

Apache Nifi: filter recordpath on boolean fields

avatar
Contributor

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

 

1 ACCEPTED SOLUTION

avatar
Contributor

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

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

 

View solution in original post

2 REPLIES 2

avatar
Contributor

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

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

 

avatar
Community Manager

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.png

 

 


Cy Jervis, Manager, Community Program
Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.