Changes

Jump to navigation Jump to search
213 bytes removed ,  18:34, 1 December 2023
m
Text replacement - "<syntaxhighlight lang="xquery">" to "<pre lang='xquery'>"
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''
|<pre>ft:search(
$db as xs:string, $terms as item()*, $options as map(*)? := ()map { }
) as text()*</pre>
|- valign="top"
* 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",
}
})
</syntaxhighlightpre>
* 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()
let $dbname := 'DB' || $db
return ft:search($dbname, $terms, map { 'fuzzy': $fuzzy })/..
</syntaxhighlightpre>
|}
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''
|<pre>ft:tokens(
$db as xs:string,
$prefix as xs:string := ()
) as element(value)*</pre>
| '''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)
</syntaxhighlightpre>
|}
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''
|<pre>ft:contains(
$input as item()*, $terms as item()*, $options as map(*)? := ()map { }
) as xs:boolean</pre>
|- valign="top"
|
* 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" })
</syntaxhighlightpre>
* Calls the function with stemming turned on and off:
<syntaxhighlight pre lang="'xquery"'>
(true(), false()) ! ft:contains("Häuser", "Haus", map { 'stemming': ., 'language':'de' })
</syntaxhighlightpre>
|}
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''
|<pre>ft:count(
$nodes as node()*
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''
|<pre>ft:score(
$item as item()*
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''
|<pre>ft:tokenize(
$string as xs:string?, $options as map(*)? := ()map { }
) as xs:string*</pre>
|- valign="top"
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''
|<pre>ft:normalize(
$string as xs:string?, $options as map(*)? := ()map { }
) as xs:string</pre>
|- valign="top"
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''
|<pre>ft:thesaurus(
$node as node(), $term as xs:string, $options as map(*)? := ()map { }
) as xs:string*</pre>
|- valign="top"
| '''Examples'''
| Returns {{Code|happy}} and {{Code|lucky}}:
<syntaxhighlight pre lang="'xquery"'>
ft:thesaurus(
<thesaurus>
'happy'
)
</syntaxhighlightpre>
|}
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''
|<pre>ft:mark(
$nodes as node()*,
$name as xs:string := ()
) as node()*</pre>
| '''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'])
</syntaxhighlightpre>
'''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
for $ft in (db:get('DB')//*[$test(.)])[position() = $start to $end]
return ft:mark($ft[$test(.)])
</syntaxhighlightpre>
'''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 ()
return ft:mark($p[text() contains text 'word'], 'b')
</syntaxhighlightpre>
|}
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''
|<pre>ft:extract(
$nodes as node()*, $name as xs:string := (),
$length as xs:integer := ()
) as node()*</pre>
|
* 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)
</syntaxhighlightpre>
|}
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu