==Full-Text Index==
The [[Full-Text]] index speeds contains the normalized tokens of text nodes of a document. It is utilized to speed up queries using with the {{Code|contains text}} expression. It provides special support for , and it is capable of processing wildcard and fuzzy search operations. Three evaluation strategies are available: the standard sequential database scan, a full-text index based evaluation and a hybrid one, combining both strategies (see [http://www.inf.uni-konstanz.de/gk/pubsys/publishedFiles/GrGaHo09.pdf XQuery Full Text implementation in BaseX]). If the full-text index exists, the following queries will all be rewritten for index access:
<pre class="brush:xquery">
(: 1st example :)
//country[name/name[text() contains text 'and'],
(: 2nd example :)
//religions[. //text() contains text { 'Catholic', 'Roman' }
using case insensitive distance at most 2 words]
</pre> The options that have been used for creating the full-text index will also be applied to the optimized full-text queries. However, the defaults can be overwritten if you supply options in your query. For example, if words were stemmed in the index, and if the query can be rewritten for index access, the query terms will be stemmed as well, unless stemming is not explicitly disabled. This is demonstrated in the following [[Commands#Command_Scripts|Command Script]]: <pre class="brush:xml"><commands> <!-- Create database with stemmed full-text index --> <set option='stemming'>true</set> <set option='ftindex'>true</set> <create-db name='test-db'> <text>house</text> </create-db> <!-- Index access: Query term will be stemmed --> <xquery> /text[. contains text { 'houses' }] </xquery> <!-- Disable stemming (query will not be evaluated by the index) --> <xquery> /text[. contains text { 'houses' } using no stemming] </xquery></commands></pre>
Text nodes can be directly requested from the index via the XQuery function [[Full-Text Module#ft:search|ft:search]]. The index contents can be accessed with [[Full-Text Module#ft:tokens|ft:tokens]].