尝试根据不同的过滤器和一个集合计算汽车数量。即使我们看到多辆汽车满足要求,查询也会返回0。
fn:count(cts:search(fn:collection("com.cars"), cts:and-query((
cts:element-word-query(xs:QName("exteriorColor"), "red", "wildcarded" ),
cts:element-word-query(xs:QName("interiorColor"), "gray", "wildcarded" )
cts:element-word-query(xs:QName("powerSteering"), json:null(), "wildcarded" )
))))
测试数据:
{
"id":1
"carName":"Toyoto",
"exteriorColor": "red",
"interiorColor": "gray",
"powerStreering": null
}
{
"id":2
"carName":"Toyoto",
"exteriorColor": "blue",
"interiorColor": "gray",
"powerStreering": null
}
{
"id":3
"carName":"Toyoto",
"exteriorColor": "red",
"interiorColor": "gray",
"powerStreering": "yes"
}
{
"id":4
"carName":"Toyoto",
"exteriorColor": "white",
"interiorColor": "gray",
"powerStreering": null
}
{
"id":5
"carName":"Toyoto",
"exteriorColor": "red",
"interiorColor": "gray",
"powerStreering": null
}
答案 0 :(得分:6)
当您需要使用cts:json-property-value-query("propertyName", json:null())
时,您正在使用by
:API Documentation
要测试null,我相信你应该使用:
merge