简体   繁体   English

Marklogic cts:文档查询

[英]Marklogic cts:document-query

Recently, I have to use MarkLogic and there are some things I don't understand. 最近,我不得不使用MarkLogic,有些事情我不了解。

I don't want you to clarify all my concerns regarding MarkLogic just one :) 我不想让您澄清我对MarkLogic的所有担忧:)

There is an XQuery and I don't understand what it does. 有一个XQuery,但我不明白它的作用。

let $pap := cts:uris(
   (), (),
   cts:and-query((
      cts:collection-query("/pageType/collection1"),
   ))
)

let $collection := ("/pageType/Attachment")
return
xdmp:estimate(
   cts:search(
      fn:doc(),
      cts:and-query((
         cts:collection-query(($collection)),
         cts:document-query($pap)
      ))
   )
)

I have huge problems to understand what the document-query function does. 我在理解文档查询功能的功能时遇到了很大的问题。

Can somebody enlighten me, please? 有人可以启发我吗? I am a beginner in MarkLogic who worked with relational databases before. 我是MarkLogic的初学者,之前曾使用关系数据库。

Thanks, 谢谢,

V. V.

Dont feel bad for not understanding this. 不要因为不了解这一点而感到难过。 Its a bit obtuse. 它有点钝。 And inefficient. 而且效率低下。

If I am reading this right what its really doing is counting the number of documents that belong to both collections "/pageType/Attachement" and "/pageType/collection1" 如果我没看错,它的实际作用是计算属于“ / pageType / Attachement”和“ / pageType / collection1”两个集合的文档数

I believe (offhand not tested) this could be vastly simplified by doing 我相信(未经测试)可以通过以下方式大大简化

xdmp:estimate( cts:search( fn:doc(), cts:and-query(( cts:collection-query("/pageType/collection1"), cts:collection-query("/pageType/Attachment") )) ) ) xdmp:estimate(cts:search(fn:doc(),cts:and-query((cts:collection-query(“ / pageType / collection1”),cts:collection-query(“ / pageType / Attachment”))) ))

I neglected to answer your first question. 我忽略了回答你的第一个问题。 cts:document-query() is documented here: cts:document-query()记录在这里:

https://docs.marklogic.com/cts:document-query https://docs.marklogic.com/cts:document-query

In this case it is acting as a filter for the return of cts:search to include only documents found by the previous query cts:uris() 在这种情况下,它充当cts:search返回的筛选器,以仅包括先前查询cts:uris()找到的文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM