How to call custom search REST API MarkLogic Data hub 5

70 Views Asked by At

I want to have a custom endpoint for search in which I can pass custom json object in body of POST Request search-custom.sjs from which I want to call a xquery module.

/data-hub/src/main/ml-modules/services/search-custom.sjs has

function post(context, params, input) { let request = JSON.parse(input)
return
xdmp.invoke("/lib/search-lib.xqy",request,[]); }

exports.POST = post

But I am unable to invoke this xquery file. Also If I call the endpoint from postman http://localhost:8011/v1/resources/search-custom body of POST Request { "searchField": "Title", "searchTerm": "xzy", "exclusionTerms":"Potential" }

I am getting the no content (204)

/lib/search-lib.xqy has this code let $_:= xdmp:log("Inside xquery search custom file") return "this is xquery"

Even the logs are not getting logged in 8011_ErrorLog.txt

So, I am not sure if I am missing anything.

Moreover, how to get the body json params into xquery module to use those in xquery.

Thanks

0

There are 0 best solutions below