Re: [External] Re: Issue with RouteOnAttribute

2018-10-15 Thread Bryan Bende
What is the syntax issue connecting EvaluateJsonPath to RouteOnAttribute ?
On Mon, Oct 15, 2018 at 1:21 PM N, Vyshali  wrote:
>
> Hi,
>
>
>
> I’m not appending the “status” attribute to the input json content. I’m just 
> using as a parameter for comparison
>
> I tried the same way connecting EvaluateJsonPath with RouteOnAttribute. I was 
> facing some syntax issue.
>
> So I took the alternative of using updateAttribute and doing the comparison
>
>
>
> My EL is ${status:contains(${result.status})}.
>
>
>
> Please let me know where I’m missing
>
>
>
> Regards
>
> Vyshali
>
>
>
> From: Sivaprasanna [mailto:sivaprasanna...@gmail.com]
> Sent: Monday, October 15, 2018 6:47 PM
> To: users@nifi.apache.org
> Subject: [External] Re: Issue with RouteOnAttribute
>
>
>
> Adding on, 'RouteOnAttribute' takes ExpressionLanguage. "$.result.status" is 
> not an ExpressionLanguage (EL) but a JSON Path expression. So what you can do 
> is, use EvaluateJsonPath processor to read the value of status using 
> "$.result.status" and assign it to an attribute, say "statusField" (this gets 
> added as a FlowFile attribute). Connect EvaluateJsonPath with 
> RouteOnAttribute and reference the attribute you have added in 
> EvaluateJsonPath using EL. Ex: ${statusField:equals("OK")}
>
>
>
> On Mon, Oct 15, 2018 at 6:31 PM Sivaprasanna  
> wrote:
>
> Vyshali,
>
>
>
> UpdateAttribute adds an attribute to the FlowFile i.e. just like filename, 
> filesize, etc., when you set "status" : "OK" using UpdateAttribute, the field 
> doesn't actually get added to the JSON content. I would rather suggest you to 
> use 'UpdateRecord' processor and configure it with JSON Reader and JSON 
> Writer (providing them with a schema for your JSON content) and set the new 
> field "status": "OK". For more details on UpdateRecord, check this tutorial. 
> https://community.hortonworks.com/articles/189642/update-the-contents-of-flowfile-by-using-updaterec.html
>
>
>
> -
>
> Sivaprasanna
>
>
>
> On Mon, Oct 15, 2018 at 6:09 PM N, Vyshali  wrote:
>
> Hi,
>
>
>
> I’m consuming the message published through “PutJMS” processor using 
> “ConsumeJMS” processor. The message is in JSON format. I added the value of 
> “status” as “OK” using “UpdateAttribute” processor. I wanted to route it to 
> “AttributesToJSON” processor if the value of $.result.status is “OK” for 
> which I’m using the “RouteOnAttribute” processor .The regular expression 
> which I used for routing is ${status:contains(${result.status})}. But the 
> routing doesn’t happen correctly.
>
>
>
> Sample input json :
>
> {
>
> "revision": "1.0.0",
>
> "acceptor": "100",
>
> "result": {
>
> "status": "OK"
>
> }
>
> }
>
>
>
> Please let me know where I’m missing.
>
> Thanks in advance
>
>
>
> Regards
>
> Vyshali


RE: [External] Re: Issue with RouteOnAttribute

2018-10-15 Thread N, Vyshali
Hi,

I’m not appending the “status” attribute to the input json content. I’m just 
using as a parameter for comparison
I tried the same way connecting EvaluateJsonPath with RouteOnAttribute. I was 
facing some syntax issue.
So I took the alternative of using updateAttribute and doing the comparison

My EL is ${status:contains(${result.status})}.

Please let me know where I’m missing

Regards
Vyshali

From: Sivaprasanna [mailto:sivaprasanna...@gmail.com]
Sent: Monday, October 15, 2018 6:47 PM
To: users@nifi.apache.org
Subject: [External] Re: Issue with RouteOnAttribute

Adding on, 'RouteOnAttribute' takes ExpressionLanguage. "$.result.status" is 
not an ExpressionLanguage (EL) but a JSON Path expression. So what you can do 
is, use EvaluateJsonPath processor to read the value of status using 
"$.result.status" and assign it to an attribute, say "statusField" (this gets 
added as a FlowFile attribute). Connect EvaluateJsonPath with RouteOnAttribute 
and reference the attribute you have added in EvaluateJsonPath using EL. Ex: 
${statusField:equals("OK")}

On Mon, Oct 15, 2018 at 6:31 PM Sivaprasanna 
mailto:sivaprasanna...@gmail.com>> wrote:
Vyshali,

UpdateAttribute adds an attribute to the FlowFile i.e. just like filename, 
filesize, etc., when you set "status" : "OK" using UpdateAttribute, the field 
doesn't actually get added to the JSON content. I would rather suggest you to 
use 'UpdateRecord' processor and configure it with JSON Reader and JSON Writer 
(providing them with a schema for your JSON content) and set the new field 
"status": "OK". For more details on UpdateRecord, check this tutorial. 
https://community.hortonworks.com/articles/189642/update-the-contents-of-flowfile-by-using-updaterec.html

-
Sivaprasanna

On Mon, Oct 15, 2018 at 6:09 PM N, Vyshali 
mailto:vyshal...@honeywell.com>> wrote:
Hi,

I’m consuming the message published through “PutJMS” processor using 
“ConsumeJMS” processor. The message is in JSON format. I added the value of 
“status” as “OK” using “UpdateAttribute” processor. I wanted to route it to 
“AttributesToJSON” processor if the value of $.result.status is “OK” for which 
I’m using the “RouteOnAttribute” processor .The regular expression which I used 
for routing is ${status:contains(${result.status})}. But the routing doesn’t 
happen correctly.

Sample input json :
{
"revision": "1.0.0",
"acceptor": "100",
"result": {
"status": "OK"
}
}

Please let me know where I’m missing.
Thanks in advance

Regards
Vyshali