Thanks Ronnen for your quick reply. I did read up the doc on cts:search.
cts:search(
$expression as node()*,
$query as cts:query?,
[$options as xs:string*],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
) as node()*
Summary:
Returns a relevance-ordered sequence of nodes specified by a given query.
Parameters:
$expression
:
An expression to be searched.
This must be an inline fully searchable path expression.
Doesn't the following mean
" $expression as node()*, " => "0 or more nodes"?
In the example given in the doc,
cts:search(//SPEECH,
cts:word-query("with flowers"))
=> ... a sequence of 'SPEECH' element ancestors (or self)
of any node containing the phrase 'with flowers'.
Doesn't //SPEECH yields all the SPEECH nodes in the XML file?
The data files I am referring to are Shakespeare XML files. I am attaching
this for your reference.
Thanks for your time and patience
Anil
From: [email protected]
To: [email protected]
Date: Fri, 2 Oct 2009 17:49:38 -0700
Subject: RE: [MarkLogic Dev General] XDMP-UNSEARCHABLE: cts:search - Expression
is unsearchable
Hi
Anil,
I’m
sure you’ll get a more robust answer on the list, but I thought I’d
shoot you a quick note since it’s fairly late on a Friday.
The
first argument to cts:search must be a single searchable path expression.
The variable $lines
represents a sequence of path expressions because $speech/LINE is
returning multiple LINE elements (LINE[1], LINE[2], etc.). You can see
this in the error message itself:
[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
It’s
a little unclear to me what you’re trying to do, but you might want to
simplify your program flow this way:
for
$speech in cts:search(doc("dream.xml")/SPEECH,
cts:word-query("with flowers"))
return
<div>
<h3>{ $speech/SPEAKER/text() }</h3>
<p>{ $speech//LINE }</p>
</div>
You’ll
see there’s a minor formatting issue with displaying $speech//LINE as I
did. I’ll leave that for you to figure out. J I hope this helps.
--Ronnen
---
Ronnen Miller
Director, Support Operations
Mark Logic Corporation
999 Skyway Road
Suite 200
San Carlos, California 94070
+1 650 655 2386 Phone
+1 650 655 2310 Fax
[email protected]
www.marklogic.com
This e-mail and any accompanying attachments are confidential. The
information is intended solely for the use of the individual to whom it is
addressed. Any review, disclosure, copying, distribution, or use of this e-mail
communication by others is strictly prohibited. If you are not the intended
recipient, please notify us immediately by returning this message to the sender
and delete all copies. Thank you for your cooperation.
From: [email protected]
[mailto:[email protected]] On Behalf Of Anil
Shekhar
Sent: Friday, October 02, 2009 4:39 PM
To: [email protected]
Subject: [MarkLogic Dev General] XDMP-UNSEARCHABLE: cts:search - Expression
is unsearchable
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( $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. Sign up
now.
_________________________________________________________________
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