|
A basic query consists of one or more phrases joined together by NEAR operators. Each phrase consists of an ordered list of one or more terms or term prefixes.
Evaluating a basic query against a row of an FTS3 table produces two outputs: a Boolean value (the result of the basic query expression) and zero or more phrase matches (used by the auxillary functions). A phrase match is a series of zero or more tokens within the row data that match a specific phrase within the basic query, and meet the 'nearness' constraints placed on the phrase by the NEAR operators to the left and right of it in the basic query (if any).
A contiguous set of tokens within a single column of the current row shall be considered a phrase match for a given phrase within the basic query if all of the following conditions are met:
Either the phrase does not have an associated column, or the contiguous set of tokens appears within the table column associated with the phrase in the basic query expression.
The number of tokens in the contiguous set is the same as the number of terms and term prefixes in the phrase.
Each token in the contiguous set that corresponds to a term (not a term prefix) in the phrase is an exact match for the term.
Each token in the contiguous set that corresponds to a term prefix (not an ordinary term) in the phrase consists of an exact match for the term prefix followed by zero or more additional characters.
The phrase is either the leftmost in the basic query, or there exists a phrase match corresponding to the phrase to the left of this one with not more than N document tokens between it and this phrase match, where N is the parameter given to the NEAR operator separating the two phrases in the basic query expression.
The phrase is either the rightmost in the basic query, or there exists a phrase match corresponding to the phrase to the right of this one with not more than N document tokens between it and this phrase match, where N is the parameter given to the NEAR operator separating the two phrases in the basic query expression.
The result of evaluating a basic query expression shall be true if the current row contains one or more phrase matches corresponding to phrases within the basic query.
The result of evaluating a basic query expression shall be false if the current row contains one or more phrase matches corresponding to phrases within the basic query.
Each phrase in an FTS3 query expression that is not part of an expression descended from the right-hand side of a NOT operator shall be considered a reportable phrase.
All phrase matches corresponding to reportable phrase within the current row shall be considered reportable phrase matches by the offsets, snippet and matchinfo functions.
The offsets function shall return a text value consisting of N integers separated by space characters, where N is a multiple of four greater than zero.
For each token in each reportable phrase match that occurs within the current row, the return value of the offsets function shall include a set of four integer values, as follows:
Within the return value of the offsets() function, the sets of four integers shall be sorted in ascending order by column number, then by byte offset, then by reportable term number.
The return value of the matchinfo function shall be a blob value containing an array of (2 + 3*R*C) unsigned 32-bit integers, where R is the number of reportable phrases in the query and C is the number of user-defined columns in the FTS3 table being queried.
The first 32-bit unsigned integer in the array returned by the matchinfo function shall contain the total number of reportable phrases in the FTS3 query.
The second 32-bit unsigned integer in the array returned by the matchinfo function shall contain the number of user defined columns in the FTS3 table, formatted as a 32-bit unsigned integer in machine byte-order.
For each reportable phrase r and each FTS3 table column c, integer (2 + r*C*3) shall contain the number of reportable phrase matches corresponding to phrase r that appear in column c of the current row.
For each reportable phrase r and each FTS3 table column c, integer (2 + r*C*3 + 1) shall contain the number of reportable phrase matches corresponding to phrase r that appear in column c of all rows in the fts3 table.
For each reportable phrase r and each FTS3 table column c, integer (2 + r*C*3 + 2) shall contain the number of fts3 table rows for which column c contains one or more reportable phrase matches corresponding to reportable phrase r.