如何在Nifi getMongo查询字段中获取ISO字符串 [英] How to get ISO string in Nifi getMongo Query Field
问题描述
我正在尝试使用表达式语言在Nifi getMongo查询字段中使用以下查询生成ISO字符串,
I'm trying to use expression languge to generate ISO string in Nifi getMongo Query field using following query,
{
"remindmeDate": {
"$gte": "${now():format("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",'GMT')}",
"$lte": "${now():toNumber():plus(359999):format("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",'GMT')}"
}
}
但是我得到了无效的JSON错误错误,因为双引号没有被转义.当我们尝试使用\运算符对其进行转义时,nifi不会评估表达式语言.有什么方法或解决方法可以使它正常工作吗?
But i'm getting invalid JSON error error as double quotes are not escaped. When we try to escape it using \ operator, nifi is not evaluating the expression language. Is there any method or workaround to get this working ?
预先感谢
推荐答案
Nifi的getMongo查询字段不支持EL.因此,我在MongoDB中为我的动态查询创建了一个存储函数,并从Nifi中调用了它.
Nifi's getMongo Query field doesnt support EL. So i created a stored function in MongoDB for my dynamic query and called it from Nifi.
{
"_id" : "reminderDateGMT",
"value" : function (reminderDateGMT) {
var reminder = new Date(reminderDateGMT)
var fromDate = new Date();
var toDate = new Date(new Date().getTime()+(1000 * 60 * 60));
if ((reminder >= fromDate) && (reminder <=toDate )) {
return true;
} else {
return false;
}
}
}
在nifi GetMongo查询中,
In nifi GetMongo Query,
{
"$where": "reminderDateGMT(this.reminderDateGMT)"
}
这篇关于如何在Nifi getMongo查询字段中获取ISO字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!