Changes

Jump to navigation Jump to search
2,445 bytes added ,  05:30, 2 May 2012
|-
| valign='top' width='90' | '''Signatures'''
|<code><b>ft:search</b>($db as item(), $terms as item()*) as text ()*</code><br/><b>ft:search</b>($db as item(), $terms as xs:stringitem()*, $options as item()) as text()*</code>
|-
| valign='top' | '''Summary'''
|Returns all text nodes from the full-text index of the database <code>[[Database Module#Database Argument|$db]]</code> that contain the text specified as {{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|element(full-text-options)}}: &lt;full-text-options/&gt;</code> must be used as root element, and the parameters are specified as child nodes, with the element name representing the key and the text node representing the value:<br /><code>&lt;full-text-options&gt;<br/>&nbsp;&nbsp;&lt;key1&gt;value1&lt;/key1&gt;<br/>&nbsp;&nbsp;...<br/>&lt;/full-text-options&gt;</code>* [[Map Module|map structure]]: all parameters can be directly represented as key/value pairs:<br /><code>map { "key1" := "value1", ... </code>}<br/>This variant is more compact, and it facilitates the binding of arbitrary data types. Note that the map structures are not part of the XQuery language yet, as the standardization is still in progress.The following keys are supported:* {{Mono|mode}}: determines the search mode (also called [http://www.w3.org/TR/xpath-full-text-10/#ftwords AnyAllOption]). Allowed values are {{Mono|any}}, {{Mono|any word}}, {{Mono|all}}, {{Mono|all words}}, and {{Mono|phrase}}. {{Mono|any}} is the default search mode.* {{Mono|fuzzy}}: turns fuzzy querying on or off. Allowed values are an empty string or {{Mono|true}}, or {{Mono|false}}. By default, fuzzy querying is turned off.* {{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'''
|'''[[XQuery Errors#BaseX Errors|BASX0001]]''' is raised if the full-text index is not available, or if the selected option is not supported by the existing index.<br/>'''[[XQuery Errors#BaseX Errors|BASX0002]]''' is raised if a referenced node is not stored in a database (i.e., references a main-memory XML fragment).<br/>'''[[XQuery Errors#BaseX Errors|BASX0021]]''' is raised if the specified full-text option is unknown.<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>ft:search("DB", "QUERY"(2010,2011), map { 'mode':='all' }} )</code><br/>returns all text nodes of the database {{Mono|DB}} that contain the string numbers {{Mono|2010}} and {{Mono|QUERY20111}}.* The last example iterates over five databases and returns all elements containing terms similar to {{Mono|Hello World}}in the text nodes:<pre class="brush:xquery">let $terms := "Hello Worlds"let $fuzzy := true()let $options := <full-text-options> <fuzzy>{ $fuzzy }</fuzzy> </full-text-options>for $db in 1 to 3let $dbname := 'DB' || $dbreturn ft:search($dbname, $terms, $options)/..</pre>
|}
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu