Hi Experts,

I am not quite sure why the expression is not search-able ... 

I followed the example in 
http://developer.marklogic.com/pubs/4.0/apidocs/SearchBuiltins.html#cts:search
But I would need your help to understand why this error and what do I need to 
do ... 

At the end of this email I am giving all the information that are relevant to 
my exercise. 

Thanks for your time and patience
Anil


Objective:

To print speaker and the line if that node contains the search string.


dream.xml

<SPEECH>
<SPEAKER>PUCK</SPEAKER>
<LINE>The king doth keep his revels here to-night:</LINE>
<LINE>Take heed the queen come not within his sight;</LINE>
<LINE>For Oberon is passing fell and wrath,</LINE>
<LINE>Because that she as her attendant hath</LINE>
<LINE>A lovely boy, stolen from an Indian king;</LINE>
<LINE>She never had so sweet a changeling;</LINE>
<LINE>And jealous Oberon would have the child</LINE>
<LINE>Knight of his train, to trace the forests wild;</LINE>
<LINE>But she perforce withholds the loved boy,</LINE>
<LINE>Crowns him with flowers and makes him all her joy:</LINE>
<LINE>And now they never meet in grove or green,</LINE>
<LINE>By fountain clear, or spangled starlight sheen,</LINE>
<LINE>But, they do square, that all their elves for fear</LINE>
<LINE>Creep into acorn-cups and hide them there.</LINE>
</SPEECH>


Reference: 

http://developer.marklogic.com/pubs/4.0/apidocs/SearchBuiltins.html#cts:search


XQuery:

declare function local:handle-doc(
       $doc      as document-node(),
       $speeches as element(SPEECH)+
    )
    {
       <h1>{ document-uri($doc) }</h1>,
       for $speech  in $speeches
       let $speaker := $speech/SPEAKER
       let $lines   := $speech/LINE
       let $searchRes := cts:search($lines, cts:word-query("with flowers"))
       return (
           if ( $searchRes ) then (
               <h3>{ $speaker/text() }</h3>,
               <p>{ $searchRes }</p>
           )
           else
           ()
       )
    };
 
    for $d in doc("/C/Users/ashekhar/Desktop/Mark Logic/Shakespeare/dream.xml")
       order by $d ascending
       return local:handle-doc($d, $d//SPEECH)
       
       
Error:

query evaluated in Shakespeare at file::C:\Users\ashekhar\Desktop\Mark 
Logic\Root as 1.0-ml (cq v4.1-1)

[1.0-ml] XDMP-UNSEARCHABLE: cts:search((doc("/C/Users/ashekhar/Desktop/Mark 
Logic/Shakespeare/dream.xml")/PLAY/ACT[1]/SCENE[1]/SPEECH[1]/LINE[1], 
doc("/C/Users/ashekhar/Desktop/Mark 
Logic/Shakespeare/dream.xml")/PLAY/ACT[1]/SCENE[1]/SPEECH[1]/LINE[2], 
doc("/C/Users/ashekhar/Desktop/Mark 
Logic/Shakespeare/dream.xml")/PLAY/ACT[1]/SCENE[1]/SPEECH[1]/LINE[3], ...), 
cts:word-query("with flowers", ("lang=en"), 1)) -- Expression is unsearchable

Stack trace:

line 10:
8: let $speaker := $speech/SPEAKER
9: let $lines := $speech/LINE
10: let $searchRes := cts:search($lines, cts:word-query("with flowers"))
11: return (
12: if ( $searchRes ) then (

local:handle-doc(doc("/C/Users/ashekhar/Desktop/Mark 
Logic/Shakespeare/dream.xml"), (doc("/C/Users/ashekhar/Desktop/Mark 
Logic/Shakespeare/dream.xml")/PLAY/ACT[1]/SCENE[1]/SPEECH[1], 
doc("/C/Users/ashekhar/Desktop/Mark 
Logic/Shakespeare/dream.xml")/PLAY/ACT[1]/SCENE[1]/SPEECH[2], 
doc("/C/Users/ashekhar/Desktop/Mark 
Logic/Shakespeare/dream.xml")/PLAY/ACT[1]/SCENE[1]/SPEECH[3], ...))

$doc := doc("/C/Users/ashekhar/Desktop/Mark Logic/Shakespeare/dream.xml")
$speeches := (doc("/C/Users/ashekhar/Desktop/Mark 
Logic/Shakespeare/dream.xml")/PLAY/ACT[1]/SCENE[1]/SPEECH[1], 
doc("/C/Users/ashekhar/Desktop/Mark 
Logic/Shakespeare/dream.xml")/PLAY/ACT[1]/SCENE[1]/SPEECH[2], 
doc("/C/Users/ashekhar/Desktop/Mark 
Logic/Shakespeare/dream.xml")/PLAY/ACT[1]/SCENE[1]/SPEECH[3], ...)
$speech := doc("/C/Users/ashekhar/Desktop/Mark 
Logic/Shakespeare/dream.xml")/PLAY/ACT[1]/SCENE[1]/SPEECH[1]
$speaker := doc("/C/Users/ashekhar/Desktop/Mark 
Logic/Shakespeare/dream.xml")/PLAY/ACT[1]/SCENE[1]/SPEECH[1]/SPEAKER
$lines := (doc("/C/Users/ashekhar/Desktop/Mark 
Logic/Shakespeare/dream.xml")/PLAY/ACT[1]/SCENE[1]/SPEECH[1]/LINE[1], 
doc("/C/Users/ashekhar/Desktop/Mark 
Logic/Shakespeare/dream.xml")/PLAY/ACT[1]/SCENE[1]/SPEECH[1]/LINE[2], 
doc("/C/Users/ashekhar/Desktop/Mark 
Logic/Shakespeare/dream.xml")/PLAY/ACT[1]/SCENE[1]/SPEECH[1]/LINE[3], ...)

line 23:
21: for $d in doc("/C/Users/ashekhar/Desktop/Mark Logic/Shakespeare/dream.xml")
22: order by $d ascending
23: return local:handle-doc($d, $d//SPEECH)

xdmp:eval("declare function local:handle-doc(&#13;&#10; $doc as ...", (), 
<options xmlns="xdmp:eval"><root>C:\Users\ashekhar\Desktop\Mark 
Logic\Root</root><isolation...</options>)

$d := doc("/C/Users/ashekhar/Desktop/Mark Logic/Shakespeare/dream.xml")
in /cq/eval.xqy line 111:

                                          
_________________________________________________________________
Your E-mail and More On-the-Go. Get Windows Live Hotmail Free.
http://clk.atdmt.com/GBL/go/171222985/direct/01/
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to