Reputation: 2192
Is there a way to return the collections of a document if you are using the search api?
I could not find a option in the Query Options Reference for that use case.
Right now i would have to build my own wrapper around the search api and find the collections of search results by myself:
xquery version "1.0-ml";
import module namespace search = "http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy";
let $docs := search:search("query")
return for $doc in $docs
return xdmp:node-collections(doc($doc/search:result/@uri))
Edit: This should be also availiable with the marklogic java client api.
Upvotes: 0
Views: 134
Reputation: 7335
To get only document metadata such as collections and not the document content, write and install a server-side transform that takes calls xdmp:node-collections() on the document and constructs a replacement document. See:
http://docs.marklogic.com/guide/java/transforms
Then call the QueryDefinition.setResponseTransform() method to specify the server-side transform:
before passing the query definition to the DocumentManager.search() method:
As a footnote, the DocumentManager.search() method can retrieve both the document metadata and content in a single request without a server-side transform by calling DocumentManager.setMetadataCategories() before searching. See:
Hoping that helps,
Upvotes: 0
Reputation: 20414
In case you are using the MarkLogic REST api, you can use the category
parameter on /v1/search
to pull up metadata
instead of content. If you would like to blend it into the search results, you best use a REST transform on /v1/search
using the transform
parameter. See also:
https://docs.marklogic.com/REST/GET/v1/search
HTH!
Upvotes: 2