Changes

Jump to navigation Jump to search
120 bytes removed ,  18:34, 1 December 2023
m
Text replacement - "<syntaxhighlight lang="xquery">" to "<pre lang='xquery'>"
* 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:
<syntaxhighlight pre lang="'xquery"'>
ft:search("db", ("A", "B"), map {
"mode": "all words",
</pre>
* Iterate over three databases and return all elements containing terms similar to {{Code|Hello World}} in the text nodes:
<syntaxhighlight pre lang="'xquery"'>
let $terms := "Hello Worlds"
let $fuzzy := true()
| '''Examples'''
|Returns the number of occurrences for a single, specific index entry:
<syntaxhighlight pre lang="'xquery"'>
let $term := ft:tokenize($term)
return number(ft:tokens('db', $term)[. = $term]/@count)
|
* Checks if {{Code|jack}} or {{Code|john}} occurs in the input string {{Code|John Doe}}:
<syntaxhighlight pre lang="'xquery"'>
ft:contains("John Doe", ("jack", "john"), map { "mode": "any" })
</pre>
* Calls the function with stemming turned on and off:
<syntaxhighlight pre lang="'xquery"'>
(true(), false()) ! ft:contains("Häuser", "Haus", map { 'stemming': ., 'language':'de' })
</pre>
| '''Examples'''
| Returns {{Code|happy}} and {{Code|lucky}}:
<syntaxhighlight pre lang="'xquery"'>
ft:thesaurus(
<thesaurus>
| '''Examples'''
|'''Example 1''': The following query returns {{Code|&lt;XML&gt;&lt;mark&gt;hello&lt;/mark&gt; world&lt;/XML&gt;}}, if one text node of the database {{Code|DB}} has the value "hello world":
<syntaxhighlight pre lang="'xquery"'>
ft:mark(db:get('DB')//*[text() contains text 'hello'])
</pre>
'''Example 2''': The following expression loops through the first ten full-text results and marks the results in a second expression:
<syntaxhighlight pre lang="'xquery"'>
let $start := 1
let $end := 10
</pre>
'''Example 3''': The following expression returns <code>&lt;xml>hello &lt;b&gt;word&lt;/b&gt;&lt;/xml&gt;</code>:
<syntaxhighlight pre lang="'xquery"'>
copy $p := <xml>hello world</xml>
modify ()
|
* The following query may return {{Code|&lt;XML&gt;...&lt;b&gt;hello&lt;/b&gt;...&lt;XML&gt;}} if a text node of the database {{Code|DB}} contains the string "hello world":
<syntaxhighlight pre lang="'xquery"'>
ft:extract(db:get('DB')//*[text() contains text 'hello'], 'b', 1)
</pre>
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu