I am very new getting started with MarkLogic and XQuery.
I am trying to create a Search Transform to return, the actual JSON from a specific level of the document
Here is a sample Document.
I would like to return the whole JSON based segment no matter where the search results are in the lower level (transcript, topics, banners etc.,)
Splashing around in the Query Console...
search:search('trump')/search:result/search:snippet//@path
Successfully Returns the path of the object, wrapped in a fn:doc
fn:doc("/20170120/NBCNightlyNews/1830/nbc")/array-node("segments")/object-node()1/transcript/node("00:00:02")/text("message")
However,
When I try to implment a similar Xpath Expression in a transform.
let $root := $content/*
return document {$root/search:result/search:snippet//@path}
And try to execute it (at no matter what the xpath expression is, besides simply $root itself there is a different failure) it returns
<error-response xmlns="http://marklogic.com/xdmp/error">
<status-code>400</status-code>
<status>Bad Request</status>
<message-code>XDMP-CHILDNODEKIND</message-code>
<message>
XDMP-CHILDNODEKIND: $root/search:result/search:snippet/descendant-or-self::node()/@path -- document nodes cannot have attribute node children
</message>
</error-response>
If I can get the transform to return the path, I can then continue on trying to evaluate the path, grab the appropriate JSON section and return.
Any thoughts?
