我在cloudant数据库中有此查询,但后端使用var db = nano.db.use(process.env.DB_NAME ||'');它不支持db.find但支持db.search。如何将查询转换为搜索参数?
var queryPifLog = {
"selector": {
"type": "piflog",
"supplier_name": "1234",
"region": {
"$in": [
"ANZ",
"GCG"
]
},
"assign_datetime":{
"$gt":assignedDate
},
"closure_datetime":{
"$lt": closedData
},
"pif_owner": {
"$in": [
"haha@163.com"
]
}
},
"fields": [
"operation",
"operator",
"type",
"region",
"country",
"supplier_name",
"operation_time",
"pif_owner"
]
};
答案 0 :(得分:1)
nano库支持db.find
,因此可以使用它。在此处查看文档:{{3}}
如果要使用Cloudant Search,则必须使用其基于Lucene的查询语言。与上述查询等效的Cloudant搜索类似于
q=type:piflog AND supplier_name:1234 AND (region:ANZ OR region:GCG) AND assign_datetime:(2018-01-01 TO *) AND closedData:(* TO 2018-10-22) AND pif_owner:haha@163.com
假设您已正确索引了字段。