Hi Yann,
the bug has been fixed; a new snapshot is available [1].
Best, Christian
[1] https://files.basex.org/releases/latest/
On Wed, Jun 4, 2025 at 1:39 PM Yann de Thézy yann.dethezy@gmail.com wrote:
Hello,
I encounter what seems to be a bug with the use of Full Text Index (basex 11.9).
I have created a database with FTINDEX (and CASESENS + DIACRITICS).
When I call once a function in the xquery below, the result is different than when I call it twice.
It seems that the whole database is searched in the case of 2 calls which is not what is expected.
Xquery is :
declare function local:getHit($documents, $word) {
(# db:enforceindex #) {
$documents//*[text() contains text {$word}]
}
};
let $docs := collection()
let $docsSmall := for $doc in $docs where $doc/book/@category='COOKING' return $doc
let $a := trace("res 1 : " || count(local:getHit($docsSmall, '2005')))
(: uncomment the line below to change getHit result :)
(: let $a := trace("res 2 : " || count(local:getHit($docsSmall, '2005'))) :)
return ''
Result is :
"res 1 : 1"
After uncommenting the second call, result is:
"res 1 : 2"
"res 2 : 2"
The same with this more simple xquery:
declare function local:getHit($documents, $word) {
(# db:enforceindex #) {
$documents//*[text() contains text {$word}]
}
};
let $docs := collection()
let $docsSmall := $docs[1]
let $a := trace("res 1 : " || count(local:getHit($docsSmall, '2005')))
return ''
Result is :
"res 1 : 2"
("res 1 : 1" expected)
2 documents are populating this database :
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
and
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
Best, Yann
https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient Sans virus.www.avast.com https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient <#m_1251767113872515045_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>