Reputation: 437
Help me to understand "fully searchable path expression". Examples of unsearchable path expressions are:
xquery version "1.0-ml";
(:constructed sequence :)
cts:search((<last_name>Mortensen</last_name>,<last_name>Hurt</last_name>,<last_name>Bello</last_name>),cts:word-query("Bello"))
or
XPATH expression that uses variables like $doc/movies//country (called "dynamic path" in "Xquery" Priscilla Walmsley book)
or
XPATH expressions that use XPath axis different than child:: or descendant::, for example:
cts:search(doc("doc/movies")/descendant::year[. = '1995']/parent::movie ,cts:word-query("Tom Stall"))
or see example MarkLogic: Understanding searchable and unsearchable queries?
What is a formal definition of "searchable path expression" ?
Upvotes: 0
Views: 440
Reputation: 7770
The clear example of what searchable path expression means is defined under the conveniently named section 'Fully Searchable Paths and cts:search Operations'..
Looking at your code, I suggest that you have a read through the Search Developer's Guide. For convenience, here is the deep link to the cts:search section.
Furthermore, you mention xQuery and reference a book or other literature. There a re many versions of xQuery - with the current W3C recommendation being version3.1. You probably want to have a look at the description of MarkLogic's implementation as it is originally derived from the 1.0 dialect and has been enhanced throughout the years.
Edit: The user has since asked for more guidance via the comments. Below is one (of many) possible solutions based on the original code sample:
xquery version "1.0-ml";
(:constructed sequence :)
let $last-name := ('Mortensen','Hurt','Bello')
return cts:search(fn:collection(),cts:and-query(
(
cts:element-word-query(xs:QName('last-name'), $last-name),
cts:word-query("Bello")
)
)
)
Upvotes: 0
Reputation: 20414
There is something special about cts:search
. You need to understand that the first argument is not evaluated before cts:search
is invoked. Instead, the expression itself is passed through to the data-layer, which then tries to resolve the expression using indexes primarily.
That is why you cannot provide constructed nodes, nor XPath expressions containing variables whose value would be unknown to the data-layer. So, that is why it speaks of (un)searchable expressions
. The performance guide (also referenced by David Ennis) puts it like this:
A fully searchable XPath expression is one that can be efficiently resolved using the indexes.
To make life easier for yourself, try using collection()
as first argument as much as possible, and provide any other constraint via the query argument.
If you need to filter constructed nodes, or the result of another expression, consider using cts:contains
.
HTH!
Upvotes: 2