1. OVERVIEWThis README file describes the syntax of the arguments that may be passed tothe FTS3 MATCH operator used for full-text queries. For example, if table"t1" is an Fts3 virtual table, the following SQL query:SELECT * FROM t1 WHERE <col> MATCH <full-text query>may be used to retrieve all rows that match a specified for full-text query.The text "<col>" should be replaced by either the name of the fts3 table(in this case "t1"), or by the name of one of the columns of the fts3table. <full-text-query> should be replaced by an SQL expression thatcomputes to a string containing an Fts3 query.If the left-hand-side of the MATCH operator is set to the name of thefts3 table, then by default the query may be matched against any columnof the table. If it is set to a column name, then by default the querymay only match the specified column. In both cases this may be overridenas part of the query text (see sections 2 and 3 below).As of SQLite version 3.6.8, Fts3 supports two slightly different queryformats; the standard syntax, which is used by default, and the enhancedquery syntax which can be selected by compiling with the pre-processorsymbol SQLITE_ENABLE_FTS3_PARENTHESIS defined.-DSQLITE_ENABLE_FTS3_PARENTHESIS2. STANDARD QUERY SYNTAXWhen using the standard Fts3 query syntax, a query usually consists of alist of terms (words) separated by white-space characters. To match aquery, a row (or column) of an Fts3 table must contain each of the specifiedterms. For example, the following query:<col> MATCH 'hello world'matches rows (or columns, if <col> is the name of a column name) thatcontain at least one instance of the token "hello", and at least oneinstance of the token "world". Tokens may be grouped into phrases usingquotation marks. In this case, a matching row or column must contain eachof the tokens in the phrase in the order specified, with no interveningtokens. For example, the query:<col> MATCH '"hello world" joe"matches the first of the following two documents, but not the second orthird:"'Hello world', said Joe.""One should always greet the world with a cheery hello, thought Joe.""How many hello world programs could their be?"As well as grouping tokens together by phrase, the binary NEAR operatormay be used to search for rows that contain two or more specified tokensor phrases within a specified proximity of each other. The NEAR operatormust always be specified in upper case. The word "near" in lower or mixedcase is treated as an ordinary token. For example, the following query:<col> MATCH 'engineering NEAR consultancy'matches rows that contain both the "engineering" and "consultancy" tokensin the same column with not more than 10 other words between them. It doesnot matter which of the two terms occurs first in the document, only thatthey be seperated by only 10 tokens or less. The user may also specifya different required proximity by adding "/N" immediately after the NEARoperator, where N is an integer. For example:<col> MATCH 'engineering NEAR/5 consultancy'searches for a row containing an instance of each specified token seperatedby not more than 5 other tokens. More than one NEAR operator can be usedin as sequence. For example this query:<col> MATCH 'reliable NEAR/2 engineering NEAR/5 consultancy'searches for a row that contains an instance of the token "reliable"seperated by not more than two tokens from an instance of "engineering",which is in turn separated by not more than 5 other tokens from aninstance of the term "consultancy". Phrases enclosed in quotes mayalso be used as arguments to the NEAR operator.Similar to the NEAR operator, one or more tokens or phrases may beseparated by OR operators. In this case, only one of the specified tokensor phrases must appear in the document. For example, the query:<col> MATCH 'hello OR world'matches rows that contain either the term "hello", or the term "world",or both. Note that unlike in many programming languages, the OR operatorhas a higher precedence than the AND operators implied between white-spaceseparated tokens. The following query matches documents that contain theterm 'sqlite' and at least one of the terms 'fantastic' or 'impressive',not those that contain both 'sqlite' and 'fantastic' or 'impressive':<col> MATCH 'sqlite fantastic OR impressive'Any token that is part of an Fts3 query expression, whether or not it ispart of a phrase enclosed in quotes, may have a '*' character appended toit. In this case, the token matches all terms that begin with the charactersof the token, not just those that exactly match it. For example, thefollowing query:<col> MATCH 'sql*'matches all rows that contain the term "SQLite", as well as those thatcontain "SQL".A token that is not part of a quoted phrase may be preceded by a '-'character, which indicates that matching rows must not contain thespecified term. For example, the following:<col> MATCH '"database engine" -sqlite'matches rows that contain the phrase "database engine" but do not containthe term "sqlite". If the '-' character occurs inside a quoted phrase,it is ignored. It is possible to use both the '-' prefix and the '*' postfixon a single term. At this time, all Fts3 queries must contain at leastone term or phrase that is not preceded by the '-' prefix.Regardless of whether or not a table name or column name is used on theleft hand side of the MATCH operator, a specific column of the fts3 tablemay be associated with each token in a query by preceding a token witha column name followed by a ':' character. For example, regardless of whatis specified for <col>, the following query requires that column "col1"of the table contains the term "hello", and that column "col2" of thetable contains the term "world". If the table does not contain columnsnamed "col1" and "col2", then an error is returned and the query isnot run.<col> MATCH 'col1:hello col2:world'It is not possible to associate a specific table column with a quotedphrase or a term preceded by a '-' operator. A '*' character may beappended to a term associated with a specific column for prefix matching.3. ENHANCED QUERY SYNTAXThe enhanced query syntax is quite similar to the standard query syntax,with the following four differences:1) Parenthesis are supported. When using the enhanced query syntax,parenthesis may be used to overcome the built-in precedence of thesupplied binary operators. For example, the following query:<col> MATCH '(hello world) OR (simple example)'matches documents that contain both "hello" and "world", and documentsthat contain both "simple" and "example". It is not possible to forumlatesuch a query using the standard syntax.2) Instead of separating tokens and phrases by whitespace, an AND operatormay be explicitly specified. This does not change query processing atall, but may be used to improve readability. For example, the followingquery is handled identically to the one above:<col> MATCH '(hello AND world) OR (simple AND example)'As with the OR and NEAR operators, the AND operator must be specifiedin upper case. The word "and" specified in lower or mixed case ishandled as a regular token.3) The '-' token prefix is not supported. Instead, a new binary operator,NOT, is included. The NOT operator requires that the query specifiedas its left-hand operator matches, but that the query specified as theright-hand operator does not. For example, to query for all rows thatcontain the term "example" but not the term "simple", the followingquery could be used:<col> MATCH 'example NOT simple'As for all other operators, the NOT operator must be specified inupper case. Otherwise it will be treated as a regular token.4) Unlike in the standard syntax, where the OR operator has a higherprecedence than the implicit AND operator, when using the enhancedsyntax implicit and explict AND operators have a higher precedencethan OR operators. Using the enhanced syntax, the following twoqueries are equivalent:<col> MATCH 'sqlite fantastic OR impressive'<col> MATCH '(sqlite AND fantastic) OR impressive'however, when using the standard syntax, the query:<col> MATCH 'sqlite fantastic OR impressive'is equivalent to the enhanced syntax query:<col> MATCH 'sqlite AND (fantastic OR impressive)'The precedence of all enhanced syntax operators, in order from highestto lowest, is:NEAR (highest precedence, tightest grouping)NOTANDOR (lowest precedence, loosest grouping)Using the advanced syntax, it is possible to specify expressions enclosedin parenthesis as operands to the NOT, AND and OR operators. However boththe left and right hand side operands of NEAR operators must be eithertokens or phrases. Attempting the following query will return an error:<col> MATCH 'sqlite NEAR (fantastic OR impressive)'Queries of this form must be re-written as:<col> MATCH 'sqlite NEAR fantastic OR sqlite NEAR impressive'
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。