Ravi
Ravi

Reputation: 1179

searchable-expression in Marklogic

How do I specify multiple XPaths in a searchable-expression in MarkLogic?

I tried the following:

let $options :=
<options xmlns="http://marklogic.com/appservices/search">
    <additional-query>
        <cts:collection-query xmlns:cts="http://marklogic.com/cts">
            <cts:uri>OncoWatch</cts:uri>
        </cts:collection-query>
    </additional-query>
     <searchable-expression xmlns:es="http://marklogic.com/entity-services"
                           xmlns:wos_dps="http://clarivate.com/schema/wok5.27/public/FullRecord">
        /es:envelope/es:raw/wos_dps:REC/wos_dps:static_data/wos_dps:summary/wos_dps:titles|
        /es:envelope/es:raw/wos_dps:REC/wos_dps:static_data/wos_dps:fullrecord_metadata/wos_dps:abstracts
    </searchable-expression>
    <term>
        <term-option>case-insensitive</term-option>
        <term-option>punctuation-insensitive</term-option>
        <term-option>whitespace-insensitive</term-option>
        <term-option>wildcarded</term-option>
    </term>
    <search-option>unfiltered</search-option>
    <transform-results apply="empty-snippet"/>
</options>

I get the following error

[1.0-ml] XDMP-UNSEARCHABLE: cts:search(fn:collection()/es:envelope/es:raw/wos_dps:REC/wos_dps:static_data/wos_dps:summary/wos_dps:titles | fn:collection()/es:envelope/es:raw/wos_dps:REC/wos_dps:static_data/wos_dps:fullrecord_metadata/wos_dps:abstracts, cts:and-query((cts:word-query("*", ("case-insensitive","punctuation-insensitive","whitespace-insensitive","wildcarded","lang=en"), 1), cts:collection-query("OncoWatch")), ()))[1 to 10] -- Expression is unsearchable

But when I try individual XPaths everything works ...

Upvotes: 1

Views: 180

Answers (3)

kcoleman
kcoleman

Reputation: 666

A searchable expression has to be single expression. You can try putting the conditional portion in the predicate (using | instead of "or" as the operator), as Elijah suggested.

You can probe for what part of your expression isn't searchable using xdmp:query-trace. Enable it, try to use your expression as an XPath expression, and then look at ErrorLog.txt to see if any segment is reported as unsearchable.

Something like this:

xquery version "1.0-ml";
(
  xdmp:query-trace(fn:true()),
  fn:doc()/your/xpath/expr/here,
  xdmp:query-trace(fn:false())
)

There's an example of the output here:

http://docs.marklogic.com/guide/performance/query_meters#id_84776

Upvotes: 3

Navin Rawat
Navin Rawat

Reputation: 3138

Please try to write something like:

<searchable-expression xmlns:xh="http://www.w3.org/1999/xhtml">
    /(xh:html | CITATION) 
</searchable-expression>

Upvotes: 0

You could add the conditional path in a single XPath expression like the following:

/es:envelope/es:raw/wos_dps:REC/wos_dps:static_data[wos_dps:summary/wos_dps:titles or wos_dps:fullrecord_metadata/wos_dps:abstracts]

Upvotes: 0

Related Questions