Created 05-12-2023 02:46 AM
Created 05-12-2023 09:33 AM
@rafy I got the same issues when I tried to create a flow using RPATH. However, here is a solution i found to dial into the data array and match on the room = A:
SELECT *
FROM FLOWFILE WHERE room = 'A'
I used QueryRecord With JSONTreeReader (see below) and JSONRecordSetWriter (default).
NiFI Flow Definition here: @gitHub
Screenshots:
Created 05-12-2023 09:42 AM
Hi @rafy ,
I dont think the QueryRecord is suppose to work this way but I could be wrong. The query record basically filters from the root array and not the nested array. Since your input is not an array json object on the root this is not going to work. and if the filter " RPATH_STRING(data, '/room')='A'" is suppose to work (not sure why its not) it will return the entire record from the root and not just the subset. I think the question has been asked before but there was no answer:
Now to resolve your problem, you have two options of processors :
Option 1: EvaluateJsonPath->QueryRecord->JsonJoltTransformation where processors are configured as follows:
EvaluateJsonPath : to get the data array into root array
QueryRecord : To Query the required record based on the ${ip} attribute:
JsonJoltTransformation: To convert back to the required schema with data array
spec:
[
{
"operation": "shift",
"spec": {
"*":"data[#].&"
}
}
]
Option 2: Just one JoltTransformationJson with the following spec:
[
{
"operation": "shift",
"spec": {
"data": {
"*": {
"room": {
"${ipAttr}": {
"@2": "data[0]"
}
}
}
}
}
}
]
Note: I had to change the ip attribute name to ipAttr since ip is reserved Expression Language function.
Created 05-13-2023 03:41 AM
Thank you so much too. This also works. But i am actually a learner using Jolt.