* Return all text nodes of the database {{Code|DB}} that contain the numbers {{Code|2010}} and {{Code|2020}}:<br/><code>ft:search("DB", ("2010", "2020"), map { 'mode': 'all' })</code>
* Return text nodes that contain the terms {{Code|A}} and {{Code|B|}} in a distance of at most 5 words:
<pre classsyntaxhighlight lang="brush:xquery">
ft:search("db", ("A", "B"), map {
"mode": "all words",
}
})
</presyntaxhighlight>
* Iterate over three databases and return all elements containing terms similar to {{Code|Hello World}} in the text nodes:
<pre classsyntaxhighlight lang="brush:xquery">
let $terms := "Hello Worlds"
let $fuzzy := true()
let $dbname := 'DB' || $db
return ft:search($dbname, $terms, map { 'fuzzy': $fuzzy })/..
</presyntaxhighlight>
|}
|
* Checks if {{Code|jack}} or {{Code|john}} occurs in the input string {{Code|John Doe}}:
<pre classsyntaxhighlight lang="brush:xquery">
ft:contains("John Doe", ("jack", "john"), map { "mode": "any" })
</presyntaxhighlight>
* Calls the function with stemming turned on and off:
<pre classsyntaxhighlight lang="brush:xquery">
(true(), false()) ! ft:contains("Häuser", "Haus", map { 'stemming': ., 'language':'de' })
</presyntaxhighlight>
|}
| '''Examples'''
|'''Example 1''': The following query returns {{Code|<XML><mark>hello</mark> world</XML>}}, if one text node of the database {{Code|DB}} has the value "hello world":
<pre classsyntaxhighlight lang="brush:xquery">
ft:mark(db:open('DB')//*[text() contains text 'hello'])
</presyntaxhighlight>
'''Example 2''': The following expression loops through the first ten full-text results and marks the results in a second expression:
<pre classsyntaxhighlight lang="brush:xquery">
let $start := 1
let $end := 10
ft:mark($ft[text() contains text { $term }])
}
</presyntaxhighlight>
'''Example 3''': The following expression returns {{Code|<p><b>word</b></p>}}:
<pre classsyntaxhighlight lang="brush:xquery">
copy $p := <p>word</p>
modify ()
return ft:mark($p[text() contains text 'word'], 'b')</presyntaxhighlight>
|}
|
* The following query may return {{Code|<XML>...<b>hello</b>...<XML>}} if a text node of the database {{Code|DB}} contains the string "hello world":
<pre classsyntaxhighlight lang="brush:xquery">
ft:extract(db:open('DB')//*[text() contains text 'hello'], 'b', 1)
</presyntaxhighlight>
|}
| '''Examples'''
|Returns the number of occurrences for a single, specific index entry:
<pre classsyntaxhighlight lang="brush:xquery">
let $term := ft:tokenize($term)
return number(ft:tokens('db', $term)[. = $term]/@count)
</presyntaxhighlight>
|}