Hi, zisedeqing:
You might consider writing queries with cts:search() so you don't need to look
into the interpretation of the FLWOR expression.
The following query should get close to what you want (though you may see some
false positives if you run unfiltered without position indexes).
cts:search(collection('test'),
cts:element-query(xs:QName("catalog"),
cts:element-attribute-value-query(xs:QName("product"),
xs:QName("dept"), "WMN")
))
As an alternative that runs unfiltered without false positives, you could
create a path range index on /catalog/product@dept and execute a
cts;path-range-query instead of the cts:element-query() above. For more
information, see:
http://docs.marklogic.com/guide/admin/range_index#id_40666
Hoping that helps,
Erik Hennum
________________________________
From: [email protected]
[[email protected]] on behalf of 张晓博 [[email protected]]
Sent: Sunday, July 05, 2015 8:33 PM
To: [email protected]
Subject: Re: [MarkLogic Dev General] General Digest, Vol 133, Issue 16
Thanks Rob , I had got the query plan by used xdmp:query-trace(), but marklogic
will really execute the xquery when i used xdmp:query-trace().
Is there another method that i can get the query plan and the query will be not
really exeuted?
>Message: 2
>Date: Mon, 6 Jul 2015 02:43:12 +0000
>From: Rob Szkutak <[email protected]>
>Subject: Re: [MarkLogic Dev General] How can i get the query plan for
> FWLOR query statement?
>To: MarkLogic Developer Discussion <[email protected]>
>Message-ID:
> <6e8e665d710d394a853b6eec145fb7dc11075...@exchg10-be02.marklogic.com>
>Content-Type: text/plain; charset="gb2312"
>
>Hi,
>
>xdmp:plan() requires a partially searchable XPath expression or a cts:search()
>expression. It doesn't accept xQuery like that. More information:
>https://docs.marklogic.com/xdmp:plan
>
>Here's an example that would work for you:
>
>xdmp:plan(collection('test')/catalog/product/@dept)
>
>Another alternative to check if your range index is being used do this:
>
>let $_ := xdmp:query-trace(fn:true())
>for $x in collection('test')/catalog/product
>where $x/@dept = 'WMN'
>return $x;
>
>This will add detailed logging information to your MarkLogic logs which you
>can use determine if your range index is being leveraged or not. The output in
>your logs is mostly identical to what you see returned from xdmp:plan()
>
>Best,
>Rob
>
>Rob Szkutak
>Associate Consultant
>MarkLogic Corporation
>[email protected]
>Cell +1.716.562.8464
>www.marklogic.com<http://www.marklogic.com>
>
>________________________________
>From: [email protected]
>[[email protected]] on behalf of ??? [[email protected]]
>Sent: Sunday, July 05, 2015 9:19 PM
>To: [email protected]
>Subject: [MarkLogic Dev General] How can i get the query plan for FWLOR query
>statement?
>
>The xquery is:
>for $x in collection('test')/catalog/product
>where $x/@dept = 'WMN'
>return $x;
>
>I had created attribute range index on product/@dept, I would like to know
>whether the query will use the range index when marklogic process it.
>so i ues the xdmp:plan to get the query plan, but i only the error :
><error:code>
>XDMP-UNSEARCHABLE
></error:code>
><error:name>
></error:name>
><error:xquery-version>
>1.0-ml
></error:xquery-version>
><error:message>
>Expression is unsearchable
></error:message>
>.......
>
>so how can i get the query plan for FWLOR query statement?
>or how can i konw whether the query will use the range index when marklogic
>process it?
>
>
>-------------- next part --------------
>An HTML attachment was scrubbed...
>URL:
>http://developer.marklogic.com/pipermail/general/attachments/20150706/f4ce97a0/attachment.html
>
>------------------------------
>
>_______________________________________________
>General mailing list
>[email protected]
>Manage your subscription at:
>http://developer.marklogic.com/mailman/listinfo/general
>
>
>End of General Digest, Vol 133, Issue 16
>****************************************
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general