Mike. Thanks for your input. This issue is resolved as part of Marklogic version 7.0.2.2. The earlier 7.0.2.1 version had this problem.
cts:contains() not working as expected in marklogic 7
-
23-06-2023 - |
Frage
I am using cts:contains() in my application in many functionalities. When I migrated to ML-7 most of the places cts:contains() not working as expected. In many cases i am doing xdmp:quote() of the first parameter to get the required results, but still I guess it is not a valid fix. Also in other cases where i use cts:reverse-query inside cts:contains, this is not possible. Is there a work around to fix this issue or i need to rework on all the cts:contain occurences? Also is there a documentation for such API changes in Marklogic 7?
Lösung 2
Andere Tipps
Changes from previous releases are in the Install Guide: http://docs.marklogic.com/guide/relnotes
The docs for cts:contains note that "Atomic values are converted to a text node before checking for a match". So the results of xdmp:unquote
are unlikely to do what you want. You'd test a text node containing serialized XML, instead of testing the original XML node.
Here's an example of cts:contains
and cts:reverse-query
from the docs. This works fine for me with 7.0-2.2, and returns true
as expected.
let $query := <query>{cts:word-query("hello")}</query>
let $x := <bar>hello</bar>
return cts:contains($query, cts:reverse-query($x))
Generally speaking cts:contains
does in-memory evaluation, and will not scale well. It is handy for working with individual in-memory documents that are not in the database. But for most purposes cts:search
or search:search
is a better choice.