The function flagged by the error message, text:match-count()
, has been deprecated and removed from eXist, as was the original eXist-specific full text search operator &=
. As a result, the article (which the history page reminds me I contributed 10 years and 3 months ago!) is in dire need of an update. These "legacy" full text features were removed from eXist because a far superior solution was added, a Lucene-based full text index, which you can read about in https://exist-db.org/exist/apps/doc/lucene.
The updated article would focus on the new Lucene-based full text index. First, create a collection configuration file, called collection.xconf
:
<collection xmlns="http://exist-db.org/collection-config/1.0">
<index xmlns:xs="http://www.w3.org/2001/XMLSchema">
<lucene>
<text qname="body"/>
<text qname="biography"/>
</lucene>
</index>
</collection>
Save this document in the /db/test
collection. eXide will save you a few steps by offering to (1) store a copy of the document where it really needs to be (in the /db/system/config/db/test
collection) and (2) reindex the /db/test
collection to apply the new collection configuration (which you could do manually with xmldb:reindex("/db/test")
):
With the collection configuration file saved as /db/system/config/db/test/collection.xconf
, you can then query the /db/test
collection using the ft:query
function and sort the results using the ft:score
function:
let $hits :=
(
collection('/db/test/articles')/article/body,
collection('/db/test/people')/people/person/biography
)[ft:query(., $q)]
for $hit in $hits
let $score := ft:score($hit)
order by $score descending
return $hit
(Notice that in contrast to the article, we can dispense with filtering the user-supplied query string, because we are no longer using util:eval
. That wasn't really necessary in the first place.)
With this change - switching to eXist's newer Lucene-based full text search engine - the rest of the article should still basically apply.