Full-text retrieval is an essential query feature for working with XML documents, and BaseX was the first query processor that fully supported the [http://www.w3.org/TR/xpath-full-text-10/ W3C XQuery Full Text 1.0] Recommendation.
=Introduction= The XQuery and XPath Full Text Recommendation (XQFT) is a feature-rich extension of the XQuery language. It can be used to both query XML documents and single strings for words and phrases. This section gives you a quick insight into the most important features of the language. This is a simple example for a basic full-text expression: <pre class="brush:xquery">"This is YOUR World" contains text "your world"</pre> It yields {{Code|true}}, because the search string is ''tokenized'' before it is compared with the tokenized input string. In the tokenization process, several normalizations take place. Many of those steps can hardly be simulated with plain XQuery: as an example, upper/lower case and diacritics (umlauts, accents, etc.) are removed and an optional, language-dependent stemming algorithm is applied. This was a quick introduction to XQuery Full Text; you are invited to explore the numerous other features of the language! ==Combining Results== XQFT expressions can also be applied on XML documents: <pre class="brush:xquery">for $country in doc('factbook')//countrywhere $country//religions[text() contains text { 'Sunni', 'Shia' } any]return $country/name</pre> In the given example, curly braces are used to combine multiple keywords. The query will output the names of all countries with a religion element containing {{Code|sunni}} or {{Code|shia}}. The {{Code|any}} keyword is optional; it can be replaced with: * {{Code|all}}: all strings need to be found* {{Code|any word}}: any of the single words within the specified strings need to be found* {{Code|all words}}: all single words within the specified strings need to be found* {{Code|phrase}}: all strings need to be found as a single phrase The keywords {{Code|ftand}}, {{Code|ftor}} and {{Code|ftnot} can also be used to combine multiple query terms. The following query yields the same result as the last one: <pre class="brush:xquery">doc('factbook')//country[.//religions/text() contains text 'sunni' ftor 'shia']/name</pre> The {{Code|not in}} keyword is special: it accepts strings contain a string which is not contained in another, longer string: <pre class="brush:xquery">for $text in ("New York", "new conditions")return $text contains text "New" not in "New York"</pre> Maby =BaseX-Specific Features=
This page lists BaseX-specific full-text features and options.