nifi-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From faustina Selvadeepa <faustin...@gmail.com>
Subject Re: Getmongo processor query field
Date Wed, 06 Sep 2017 07:06:48 GMT
Hi Koji,

Thanks a lot for your response.
The above code removed the JsonParseException, but it is fetching all the
data from the database. It's not executing my function call dd(). Is there
a way to make a function call in the same query?

Thanks,
Faustina


On 6 September 2017 at 10:47, Koji Kawamura <ijokarumawak@gmail.com> wrote:

> Hi Faustina,
>
> I'm not familiar with MongoDB query syntax, but based on the
> Stackoverflow answer, to avoid JsonParseException and query a field
> containing space, something like below may work? i.e. escaping the
> double quotes
>
> {"$where": "\"Incident Submitted Dt\" >= dd()"}
>
>
> Thanks,
> Koji
>
> On Wed, Sep 6, 2017 at 1:18 PM, faustina Selvadeepa
> <faustina93@gmail.com> wrote:
> > Hi,
> >
> > I want my getmongo processor to fetch the data of past 2 days only. So I
> > referred this link to create a function and call that function from the
> > query field in getmongo processor:
> > https://stackoverflow.com/questions/44573618/how-to-get-
> iso-string-in-nifi-getmongo-query-field/44725438#44725438
> >
> > Function to get a date:
> >
> > db.system.js.save({
> >
> >     "_id": "dd",
> >
> >     "value": function() {
> >
> >           var todayTime = new Date();
> >
> >     var yesterday = new Date()
> >
> >          yesterday.setDate(todayTime.getDate() - 2)
> >
> >     var month = yesterday.getMonth() + 1;
> >
> >     var day = yesterday.getDate();
> >
> >     var year = yesterday.getFullYear().toString().substr(-2);
> >
> >     var prev_date=month + "/" + day + "/" + year;
> >
> >     return prev_date;
> >
> > }
> >
> > });
> >
> > Query to fetch all the data that is greater than the calculated date:
> >
> > {"$where": "Incident Submitted Dt": $gte: dd()}
> >
> > I am getting a Json parse exception in the processor:
> >
> > 'Query validated against '{"$where": "Incident Submitted Dt": $gte:
> dd()}'
> > is invalid because org.son.json.JsonParseException.
> >
> >
> > I am sure the query is wrong, but I don't know how to write a valid
> query.
> >
> >
> > Request you to help!!
> >
> >
> > Thanks,
> >
> > Faustina
>

Mime
View raw message