Changes

Jump to navigation Jump to search
225 bytes removed ,  00:42, 26 May 2012
m
Text replace - "| valign='top' | " to "| "
|<code><b>ft:search</b>($db as item(), $terms as item()*) as text()*</code><br/><code><b>ft:search</b>($db as item(), $terms as item()*, $options as item()) as text()*</code>
|-
| valign='top' | '''Summary'''
|Returns all text nodes from the full-text index of the [[Database Module#Database Nodes|database node]] <code>$db</code> that contain the specified {{Mono|$terms}}.<br/>The options used for building the full-text will also be applied to the search terms. As an example, if the index terms have been stemmed, the search string will be stemmed as well.
The {{Mono|$options}} argument can be used to overwrite the default full-text options. It can be specified as
* {{Mono|wildcards}}: turns wildcard querying on or off. Allowed values are an empty string or {{Mono|true}}, or {{Mono|false}}. By default, wildcard querying is turned off.
|-
| valign='top' | '''Errors'''
|'''[[Database Module#Errors|BXDB0004]]''' is raised if the full-text index is not available.<br/>'''[[XQuery Errors#BaseX Errors|BASX0022]]''' is raised if both fuzzy and wildcard querying has been selected.
|-
| valign='top' | '''Examples'''
|
* <code>ft:search("DB", "QUERY")</code> returns all text nodes of the database {{Mono|DB}} that contain the term {{Mono|QUERY}}.
|<code><b>ft:mark</b>($nodes as node()*) as node()*</code><br /><code><b>ft:mark</b>($nodes as node()*, $tag as xs:string) as node()*</code>
|-
| valign='top' | '''Summary'''
|Puts a marker element around the resulting <code>$nodes</code> of a full-text index request.<br />The default tag name of the marker element is <code>mark</code>. An alternative tag name can be chosen via the optional <code>$tag</code> argument.<br />Note that the XML node to be transformed must be an internal "database" node. The <code>transform</code> expression can be used to apply the method to a main-memory fragment (see example).
|-
| valign='top' | '''Examples'''
|
* The following query returns <code>&lt;XML&gt;&lt;mark&gt;hello&lt;/mark&gt; world&lt;/XML&gt;</code>, if one text node of the database <code>DB</code> has the value "hello world":
|<code><b>ft:extract</b>($nodes as node()*) as node()*</code><br /><code><b>ft:extract</b>($nodes as node()*, $tag as xs:string) as node()*</code><br /><code><b>ft:extract</b>($nodes as node()*, $tag as xs:string, $length as xs:integer) as node()*</code>
|-
| valign='top' | '''Summary'''
|Extracts and returns relevant parts of full-text results. It puts a marker element around the resulting <code>$nodes</code> of a full-text index request and chops irrelevant sections of the result.<br />The default tag name of the marker element is <code>mark</code>. An alternative tag name can be chosen via the optional <code>$tag</code> argument.<br />The default length of the returned text is <code>150</code> characters. An alternative length can be specified via the optional <code>$length</code> argument. Note that the effective text length may differ from the specified text due to formatting and readibility issues.
|-
| valign='top' | '''Examples'''
|
* The following query may return <code>&lt;XML&gt;...&lt;b&gt;hello&lt;/b&gt;...&lt;XML&gt;</code> if a text node of the database <code>DB</code> contains the string "hello world":
|<code><b>ft:count</b>($nodes as node()*) as xs:integer</code>
|-
| valign='top' | '''Summary'''
|Returns the number of occurrences of the search terms specified in a full-text expression.
|-
| valign='top' | '''Examples'''
|
* <code>ft:count(//*[text() contains text 'QUERY'])</code> returns the <code>xs:integer</code> value <code>2</code> if a document contains two occurrences of the string "QUERY".
|<code><b>ft:score</b>($item as item()*) as xs:double*</code>
|-
| valign='top' | '''Summary'''
|Returns the score values (0.0 - 1.0) that have been attached to the specified items. <code>0</code> is returned a value if no score was attached.
|-
| valign='top' | '''Examples'''
|
* <code>ft:score('a' contains text 'a')</code> returns the <code>xs:double</code> value <code>1</code>.
|{{Mono|<b>ft:tokens</b>($db as item()) as element(value)*}}<br/>{{Mono|<b>ft:tokens</b>($db as item(), $prefix as xs:string) as element(value)*}}
|-
| valign='top' | '''Summary'''
|Returns all full-text tokens stored in the index of the [[Database Module#Database Nodes|database node]] <code>$db</code>, along with their numbers of occurrences.<br/>If {{Mono|$prefix}} is specified, the returned nodes will be refined to the strings starting with that prefix. The prefix will be tokenized according to the full-text used for creating the index.
|-
| valign='top' | '''Errors'''
|'''[[Database Module#Errors|BXDB0004]]''' is raised if the full-text index is not available.
|}
|{{Mono|<b>ft:tokenize</b>($input as xs:string) as xs:string*}}
|-
| valign='top' | '''Summary'''
|Tokenizes the given {{Mono|$input}} string, using the current default full-text options.
|-
| valign='top' | '''Examples'''
|
* <code>ft:tokenize("No Doubt")</code> returns the two strings {{Mono|no}} and {{Mono|doubt}}.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu