Hi Tim,

cts:search is not exactly a normal function, even though a developer can, for 
the most part, treat it that way (I think the technical term for it is a 
"special form").  The intent of the signature in the documentation is that the 
XPath expression you put for the first argument returns node()*; that is, the 
XPath can return empty.  But the expression itself cannot be empty.

I hope that helps to clear it up.

-Danny

From: [email protected] 
[mailto:[email protected]] On Behalf Of Tim Meagher
Sent: Friday, August 12, 2011 9:42 AM
To: 'General MarkLogic Developer Discussion'
Subject: Re: [MarkLogic Dev General] What is the syntax for supplying multiple 
expressiosn in cts:search?

Hi Danny,

That sounds good to me.  The 4.1 documentation implies that multiple or no 
expressions are valid:

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()*

Why is that?

I also found that it does not like supplying the empty set for the expression, 
i.e.:

cts:search((), $query)

Thanks!

Tim

From: [email protected] 
[mailto:[email protected]] On Behalf Of Danny Sokolsky
Sent: Friday, August 12, 2011 12:31 PM
To: General MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] What is the syntax for supplying multiple 
expressiosn in cts:search?

Hi Tim,

You can only search one path and it has to be "searchable".  A searchable path 
is a subset of XPath, and you can tell if it is searchable by trying it in a 
cts:search and seeing if it throws an exception.  If it does not throw an 
exception, it is searchable.

In general, you can use unions, so I think this form will work:

cts:search(/(foo | bar)//bar, "hello")

-Danny

From: [email protected] 
[mailto:[email protected]] On Behalf Of Tim Meagher
Sent: Friday, August 12, 2011 9:22 AM
To: 'General MarkLogic Developer Discussion'
Subject: [MarkLogic Dev General] What is the syntax for supplying multiple 
expressiosn in cts:search?

I'd like to search multiple paths for a given query when using cts:search.  
Given one path it works fine, i.e.

cts:search(/ns1:el1, $query)

But what if I want to query in multiple paths, e.g.

cts:search((/ns1:el1, //ns2:el1), $query)

This doesn't seem to work...

Tim

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to