问题
I have the following expression:
let $q1 := cts:element-range-query(xs:QName("ts:week"), ">=" ,xs:date("2009-04-25"))
return cts:search(fn:doc(), $q1, "unfiltered")
I did a xdmp:plan
, and got to know that range indexes are being used and the expression is searchable
However, when I added a XPath:
let $q1 := cts:element-range-query(xs:QName("ts:week"), ">=" ,xs:date("2009-04-25"))
return cts:search(fn:doc(), $q1, "unfiltered")/ts:top-song/ts:title/text()
On doing a xdmp:plan
, it told me the path is unsearchable. Further on doing in query-trace it said other than fn:doc()
nothing searchable.
However, since I am getting the correct result. My guess is that indexes are working just fine.
If so, what is logging the message "unsearchable" ?
I specifically need the title element in this case, is there anything I can do to make the entire expression searchable ?
回答1:
This code is doing two things:
- Executing a search to get a sequence of documents
- Applying an XPath to the sequence of documents to extract nodes from the documents
To put it another way, the XPath is not part of the search. It applies post-processing to the results of the search.
Both xdmp:estimate()
and xdmp:plan()
accept only the input to the search and not the post-processing on the results of the search.
Hoping that clarifies,
回答2:
If there were an element range index on the ts:title
element, you could use cts:element-values() to retrieve the titles by applying the $q1
query, and that would be an index-resolved operation.
For example:
cts:element-values(xs:QName("ts:title"), "", (), $q1)
来源:https://stackoverflow.com/questions/45278015/marklogic-understanding-searchable-and-unsearchable-queries