Changes

Jump to navigation Jump to search
153 bytes added ,  15:37, 27 February 2020
no edit summary
* 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|&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":
<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|&lt;p&gt;&lt;b&gt;word&lt;/b&gt;&lt;/p&gt;}}:
<pre classsyntaxhighlight lang="brush:xquery">
copy $p := &lt;p&gt;word&lt;/p&gt;
modify ()
return ft:mark($p[text() contains text 'word'], 'b')</presyntaxhighlight>
|}
|
* 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":
<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>
|}
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu