Mike,

I was unclear — the expression language has to be evaluated during the 
UpdateAttribute processor currently, but with the resolution of the ticket I 
referenced, you would be able to evaluate it inline in the GetMongo processor.

Glad you found a solution that works for you and thank you for sharing.

Andy LoPresto
[email protected]
[email protected]
PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4  BACE 3C6E F65B 2F7D EF69

> On Jun 23, 2017, at 11:45 AM, Mike Thomsen <[email protected]> wrote:
> 
> Thanks Andy. Didn't quite do the job because EL is not usable on the query 
> field in my version, but this is what I did in case someone else wants to try 
> it:
> 
> Mongo console:
> 
> db.system.js.save({
>     "_id": "lastFiveMinutes",
>     "value": function() {
>         return new Date(ISODate().getTime() - (1000 * 60 * 5));
>     }
> });
> db.loadServerScripts();
> 
> Query field:
> 
> {
>     "$where": "obj.ts >= lastFiveMinutes()"
> }
> 
> On Fri, Jun 23, 2017 at 10:08 AM, Andy LoPresto <[email protected] 
> <mailto:[email protected]>> wrote:
> Mike,
> 
> The query is failing JSON validation because the value of the “$gte” key is 
> not valid JSON. You should be able to use a combination of NiFi Expression 
> Language [1] and the UpdateAttribute processor [2] to populate the expected 
> date value in your query. Once NIFI-4082 [3] is implemented, you won’t need 
> the UpdateAttribute processor anymore.
> 
> [1] 
> https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html 
> <https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html>
> [2] https://stackoverflow.com/a/44585760/70465 
> <https://stackoverflow.com/a/44585760/70465>
> [3] https://issues.apache.org/jira/browse/NIFI-4082 
> <https://issues.apache.org/jira/browse/NIFI-4082>
> 
> Andy LoPresto
> [email protected] <mailto:[email protected]>
> [email protected] <mailto:[email protected]>
> PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4  BACE 3C6E F65B 2F7D EF69
> 
>> On Jun 23, 2017, at 9:06 AM, Mike Thomsen <[email protected] 
>> <mailto:[email protected]>> wrote:
>> 
>> I am trying to write a query for GetMongo that gives me documents added in
>> the last five minutes. It looks like this:
>> 
>> {
>>    "ts": {
>>        "$gte": new Date(ISODate().getTime() - (1000 * 60 * 5))
>>    }
>> }
>> 
>> The processor goes to an invalid state because it says "query validated
>> against [that query] is invalid because org.bosn.json.JsonParseException."
>> Does anyone know how to convert that query from the Mongo command
>> shell-acceptable syntax into one NiFi can accept?
>> 
>> Thanks,
>> 
>> Mike
> 
> 

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to