|
|
xdmp:plan(
|
|
$expression as item()*,
|
|
[$maximum as xs:double?]
|
| ) as element() |
|
 |
Summary:
Returns an XML element recording information about how the given
expression will be processed by the index. The information is a
structured representation of the information provided in the error log
when query trace is enabled. The query will be processed up to the
point of getting an estimate of the number of fragments returned by the
index.
|
Parameters:
$expression
:
The expression to estimate.
This must be a partially searchable XPath expression
or a cts:search() expression.
|
$maximum
(optional):
The maximum value to return.
Stop selecting fragments if this number is reached.
|
|
Usage Notes:
The output from xdmp:plan will vary depending on various index
settings.
Running an xdmp:plan on a search is similar to running an
xdmp:estimate on a search, but it returns a report on the
search instead of just an estimate. As part of the report, the
qry:result element includes the estimate.
If the search expression argument cannot be run in the
plan because it is not partially searchable, then an
XDMP-UNSEARCHABLE exception is returned as part of the
xdmp:plan output.
If you are running a search using the search API
(for example, search:search), use the
option <return-plan>true</return-plan> in your
search API options node.
|
Example:
xdmp:plan(cts:search(fn:doc(),cts:word-query("cat")))
=>
<qry:query-plan xmlns:qry="http://marklogic.com/cts/query">
<qry:info-trace>xdmp:eval("xquery version &quot;1.0-ml&quot;;&#13;
&#10;xdmp:plan(cts:search...", (), <options xmlns="xdmp:eval"><
default-xquery-version>0.9-ml</default-xquery-version><root
>c:/...</options>)</qry:info-trace>
<qry:info-trace>Analyzing path for search: fn:doc()</qry:info-trace>
<qry:info-trace>Step 1 is searchable: fn:doc()</qry:info-trace>
<qry:info-trace>Path is fully searchable.</qry:info-trace>
<qry:info-trace>Gathering constraints.</qry:info-trace>
<qry:word-trace text="cat">
<qry:key>12545744176132597186</qry:key>
</qry:word-trace>
<qry:info-trace>Search query contributed 1 constraint:
cts:word-query("cat", ("lang=en"), 1)</qry:info-trace>
<qry:partial-plan>
<qry:term-query weight="1">
<qry:key>12545744176132597186</qry:key>
</qry:term-query>
</qry:partial-plan>
<qry:info-trace>Executing search.</qry:info-trace>
<qry:final-plan>
<qry:and-query>
<qry:term-query weight="1">
<qry:key>12545744176132597186</qry:key>
</qry:term-query>
</qry:and-query>
</qry:final-plan>
<qry:info-trace>Selected 2 fragments to filter</qry:info-trace>
<qry:result estimate="2"/>
</qry:query-plan>
|
Example:
xquery version "1.0-ml" ;
xdmp:plan(
cts:search(/document,
cts:word-query("cut?",
("unstemmed", "wildcarded") ) ) )
(:
The <qry:expansion-trace> element indicates that a
lexicon expansion occurred on the wildcarded query
(word searches, three character searches and
a codepoint lexicon are enabled in the database
configuration for wildcard queries). The
<qry:expansion> element shows what term(s) the
lexicon expansion found. In this case, "cut?"
expands to "cute".
:)
=>
<qry:query-plan xmlns:qry="http://marklogic.com/cts/query">
<qry:info-trace>xdmp:eval("xquery version &quot;1.0-ml&quot; ;
&#13;&#10;&#13;&#10;xdmp:plan...", (),
<options xmlns="xdmp:eval"><database>
13960881382049922482</database><default-xquery-version...
</options>)</qry:info-trace>
<qry:info-trace>Analyzing path for search: fn:collection()/document
</qry:info-trace>
<qry:info-trace>Step 1 is searchable: fn:collection()</qry:info-trace>
<qry:info-trace>Step 2 is searchable: document</qry:info-trace>
<qry:info-trace>Path is fully searchable.</qry:info-trace>
<qry:info-trace>Gathering constraints.</qry:info-trace>
<qry:expansion-trace text="cut?">
<qry:expansion text="cute"/>
</qry:expansion-trace>
<qry:word-trace text="cute">
<qry:key>16588943567160478160</qry:key>
</qry:word-trace>
<qry:info-trace>Search query contributed 1 constraint:
cts:word-query("cut?", ("unstemmed","wildcarded","lang=en"), 1)
</qry:info-trace>
<qry:partial-plan>
<qry:term-query weight="1">
<qry:key>16588943567160478160</qry:key>
</qry:term-query>
</qry:partial-plan>
<qry:info-trace>Executing search.</qry:info-trace>
<qry:final-plan>
<qry:and-query>
<qry:or-two-queries>
<qry:term-query weight="0">
<qry:key>3998944933214536873</qry:key>
</qry:term-query>
<qry:term-query weight="0">
<qry:key>13616698357625443361</qry:key>
</qry:term-query>
</qry:or-two-queries>
<qry:term-query weight="1">
<qry:key>16588943567160478160</qry:key>
</qry:term-query>
</qry:and-query>
</qry:final-plan>
<qry:info-trace>Selected 1 fragment to filter</qry:info-trace>
<qry:result estimate="1"/>
</qry:query-plan>
|
|
|