0

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" ?

mg_kedzie
  • 337
  • 1
  • 9

2 Answers2

2

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!

grtjn
  • 20,254
  • 1
  • 24
  • 35
0

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")
            )
          )
         ) 
  • The code was suppose to show that constructed sequence is not searchable and gives XDMP-UNSEARCHABLE error. What is wrong, please rewrite. – mg_kedzie Nov 17 '17 at 23:53
  • @mg_kedzie : your original post does not ask for a fix of your code. it asked for someone to provide the definition of 'searchable expressions' I provided that. I also went further to show you where to learn about cts queries since it was clear that you needed to revise your knowledge of the two items and how they work together. I would have expected that you would then have had the knowledge needed to formulate a properly constructed query. In all cases, a sample is provided based on your sample. For that, I had to make assumptions. – David Ennis -CleverLlamas.com Nov 18 '17 at 08:01