如何获得Marklogic Xquery中具有特定值的特定记录的计数
我正在尝试获得给定条件的记录。
计算辅助价格大于1000的集合中所有文档中的辅助价格的数量。
我正在尝试以下Xquery,这给了我以下响应:
在9007.0781 ms中返回了532个项目的序列。 (与先前的运行相比-361.0691 ms。)
,并在所有532行中在每行中打印1个值。
但是,我的预期结果是将计数作为结果:532在我的结果页面中。
您可以在这里帮助确定Xquery问题吗?
xquery version "1.0-ml";
for $x in collection("GTM2_Shipment")
where ($x/*:Shipment/*:Ancillary/*:QuotePrice/text() > 1000)
return (count($x))
I am trying to get count of a record for a given condition.
Count the number of Ancillary Price in all documents in a collection where the Ancillary Price is greater than 1000.
I am trying the below XQuery for that, it gives me this below response:
Returned sequence of 532 items in 9007.0781 ms. (-361.0691 ms. compared to previous run)
And along with it prints value of 1 in each row for all 532 rows.
However my expected result is to get the count as result: 532 in my result page.
Can you please help to identify the XQuery issue here?
xquery version "1.0-ml";
for $x in collection("GTM2_Shipment")
where ($x/*:Shipment/*:Ancillary/*:QuotePrice/text() > 1000)
return (count($x))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
结构略有不正确。
参考: https://wwwwww.w3schools.com/xml/xml/xml/xquery_flwor.asp
em>尝试:
或简单地:
,最终将不会扩展。
对您自己的文档中每个装运的数据进行建模,然后您可以使用以下估算值:
The structure is slightly incorrect.
Ref: https://www.w3schools.com/xml/xquery_flwor.asp
Try:
Or simply:
However, eventually these will not scale.
Model your data where each shipment is in it's own document and then you can use an estimate such as: