Search code examples
javamarklogic

MarkLogic Search return document collections


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.


Solution

  • 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!