简体   繁体   中英

Marklogic cts:document-query

Recently, I have to use MarkLogic and there are some things I don't understand.

I don't want you to clarify all my concerns regarding MarkLogic just one :)

There is an XQuery and I don't understand what it does.

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.

Thanks,

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"

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") )) ) )

I neglected to answer your first question. cts:document-query() is documented here:

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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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