exist
exist copied to clipboard
[BUG] matches is not being handled by the range module
While working on issue #3620, I noticed that matches is not being handled by the Range Index module.
For example, these queries are being handled by the Range Index module:
collection("/db/test")//foo[@bar eq "baz"]
collection("/db/test")//foo[contains(@bar, "b")]
collection("/db/test")//foo[starts-with(@bar, "b")]
The exception is the following query:
collection("/db/test")//foo[matches(@bar, "^b")]
Which is not handled by the Range Index, and whilst debugging this, I was unable to trigger any breakpoints within the Range Index module.
The code for matches is here: https://github.com/eXist-db/exist/blob/develop/exist-core/src/main/java/org/exist/xquery/functions/fn/FunMatches.java
See below for the full test:
xquery version "3.1";
let $data :=
<root>
<foo bar="baz"/>
</root>
let $old-range-xconf :=
<collection xmlns="http://exist-db.org/collection-config/1.0">
<index xmlns:xs="http://www.w3.org/2001/XMLSchema">
<create qname="@bar" type="xs:string"/>
</index>
</collection>
let $new-range-xconf :=
<collection xmlns="http://exist-db.org/collection-config/1.0">
<index xmlns:xs="http://www.w3.org/2001/XMLSchema">
<range>
<create qname="@bar" type="xs:string"/>
</range>
</index>
</collection>
let $test-col := xmldb:create-collection("/db", "test")
let $xconf-col := xmldb:create-collection("/db/system/config/db", "test")
let $conf := for $col in ("old-range-index", "new-range-index", "no-range-index")
return
(
xmldb:create-collection("/db/test", $col),
xmldb:create-collection("/db/system/config/db/test", $col),
xmldb:store("/db/test/" || $col, "test.xml", $data)
)
let $store-xconf-old := xmldb:store("/db/system/config/db/test/old-range-index", "collection.xconf", $old-range-xconf)
let $store-xconf-new := xmldb:store("/db/system/config/db/test/new-range-index", "collection.xconf", $new-range-xconf)
let $reinedx := xmldb:reindex("/db/test")
(:let $hits := collection("/db/test")//foo[@bar eq "baz"]:)
let $hits := collection("/db/test")//foo[matches(@bar, "^b")]
(:let $hits := collection("/db/test")//foo[contains(@bar, "b")]:)
(:let $hits := collection("/db/test")//foo[starts-with(@bar, "b")]:)
for $hit in $hits
return util:collection-name($hit)
@marmoure this was completed without a PR being merged? Could you explain what the outcome was?
It was closed by mistake.