Reputation: 1510
I stored documents in Marklogic like below,
Collection : system, user
Documents Stored
1. /system/user/1
2. /system/user/2
Collection : system, role
Documents Stored
1. /system/role/1
2. /system/role/2
Collection : system, access
Documents Stored
1. /system/access/1
2. /system/access/2
Now my requirement is i want all the documents which are only the part of system, access collection so i tried,
for $doc in cts:search(collection(("system", "access")), ())
return
(
document-uri($doc)
)
after executing above code here i am expecting /system/access/1, /system/access/2 because these two documents are only part of "system", "access" collection but here i am getting all the documents from Collection : system, user, Collection : system, role. I am not able to understand wrong with about Code or i am missing something.
Please help me to Fix this Issue.
Upvotes: 2
Views: 91
Reputation: 348
The Problem with your code is as below-
All the 6 documents which you have stored are part of "System" collection.
So obviously whenever you will try to give collection("system"), it will fetch all documents.
The other scenario can be- Suppose you want to retrieve the document which are part of "user" and "access" collection. In that case you can use cts:and-query inside cts:search query.
Hope that Helps !
Upvotes: 4