Hi BaseXers,
Consider the following query run on a database 'factbook' containing
factbook.xml with full-text indexing:
declare function local:search(
$database as xs:string,
$query as xs:string
) {
let $country-search := ft:search($database, $query)/ancestor::country
let $city-search := ft:search($database,
$query)/ancestor::city/ancestor::country
let $other-search := ft:search($database, $query)/parent::*[name() =
('ethnicgroups', 'languages')]/ancestor::country
let $country-mark := $country-search[.//name[text() contains text {
$query }]] => ft:mark()
let $city-mark := $city-search[.//city[text() contains text { $query
}]] => ft:mark()
let $other-mark := $other-search[.//*[name() = ('ethnicgroups',
'languages')][text() contains text { $query }]] => ft:mark()
return (
$country-mark,
$city-mark,
$other-mark
)
};
local:search('factbook', 'German')
The first result of this query is the entry for Austria. I would expect
both of the instances of the word 'German' in that entry to be surrounded
by <mark> tags. However only the first instance is.
Some changes that produce the correct result for the Austria entry:
- replacing $database with 'factbook' in the definition of $other-search,
or
- deleting either $country-mark or $city-mark in the sequence returned.
If you make either of the above changes, but additionally change the
predicate [text() contains text { $query }] to [ft:contains(text(),
$query)], the incorrect result returns.
Any idea what might be causing this? I'm running BaseX 10.7.
Cheers,
Jack