Documentation Source Text

Check-in [58bbcf8b2f]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add a description of the "^" syntax to fts5.in.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 58bbcf8b2f2ea339eca791a46ecc24ceb644cb66983d09114ec08b7bb809a0fe
User & Date: dan 2017-11-25 14:02:15.511
Context
2017-11-25
15:22
Update the fts5 documentation to make it clear that the xDestroy function is not invoked if either xCreateFunction or xCreateTokenizer fails. (check-in: 820de7c995 user: dan tags: trunk)
14:02
Add a description of the "^" syntax to fts5.in. (check-in: 58bbcf8b2f user: dan tags: trunk)
2017-11-13
23:06
Continuing work on the walformat.html document. (check-in: 74c71c744b user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to pages/fts5.in.
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
The following block contains a summary of the FTS query syntax in BNF form.
A detailed explanation follows.

<codeblock>
&lt;phrase&gt;    := string &#91;*]
&lt;phrase&gt;    := &lt;phrase&gt; + &lt;phrase&gt;
&lt;neargroup&gt; := NEAR ( &lt;phrase&gt; &lt;phrase&gt; ... &#91;, N] )
&lt;query&gt;     := &#91; &#91;-] &lt;colspec&gt; :] &lt;phrase&gt;
&lt;query&gt;     := &#91; &#91;-] &lt;colspec&gt; :] &lt;neargroup&gt;
&lt;query&gt;     := &#91; &#91;-] &lt;colspec&gt; :] ( &lt;query&gt; )
&lt;query&gt;     := &lt;query&gt; AND &lt;query&gt;
&lt;query&gt;     := &lt;query&gt; OR &lt;query&gt;
&lt;query&gt;     := &lt;query&gt; NOT &lt;query&gt;
&lt;colspec&gt;   := colname
&lt;colspec&gt;   := { colname1 colname2 ... }







|







169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
The following block contains a summary of the FTS query syntax in BNF form.
A detailed explanation follows.

<codeblock>
&lt;phrase&gt;    := string &#91;*]
&lt;phrase&gt;    := &lt;phrase&gt; + &lt;phrase&gt;
&lt;neargroup&gt; := NEAR ( &lt;phrase&gt; &lt;phrase&gt; ... &#91;, N] )
&lt;query&gt;     := &#91; &#91;-] &lt;colspec&gt; :] &#91;&#94;] &lt;phrase&gt;
&lt;query&gt;     := &#91; &#91;-] &lt;colspec&gt; :] &lt;neargroup&gt;
&lt;query&gt;     := &#91; &#91;-] &lt;colspec&gt; :] ( &lt;query&gt; )
&lt;query&gt;     := &lt;query&gt; AND &lt;query&gt;
&lt;query&gt;     := &lt;query&gt; OR &lt;query&gt;
&lt;query&gt;     := &lt;query&gt; NOT &lt;query&gt;
&lt;colspec&gt;   := colname
&lt;colspec&gt;   := { colname1 colname2 ... }
250
251
252
253
254
255
256


















257
258
259
260
261
262
263
</codeblock>

<p>The final query in the block above may not work as expected. Because the
"*" character is inside the double-quotes, it will be passed to the tokenizer,
which will likely discard it (or perhaps, depending on the specific tokenizer
in use, include it as part of the final token) instead of recognizing it as
a special FTS character.



















<h2 tags="FTS5 NEAR queries">FTS5 NEAR Queries</h2>

<p>Two or more phrases may be grouped into a <b>NEAR group</b>. A NEAR group
is specified by the token "NEAR" (case sensitive) followed by an open
parenthesis character, followed by two or more whitespace separated phrases, optionally followed by a comma and the numeric parameter <i>N</i>, followed by
a close parenthesis. For example:







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
</codeblock>

<p>The final query in the block above may not work as expected. Because the
"*" character is inside the double-quotes, it will be passed to the tokenizer,
which will likely discard it (or perhaps, depending on the specific tokenizer
in use, include it as part of the final token) instead of recognizing it as
a special FTS character.

<h2 tags="FTS5 initial token queries">FTS5 Initial Token Queries</h2>
<p>
If a "&#94;" character appears immediately before a phrase that is not part of a
NEAR query, then that phrase only matches a document only if it starts at the
first token in a column. The "&#94;" syntax may be combined with a 
[FTS5 column filters|column filter], but may not be inserted into the middle of
a phrase.

<codeblock>
  ... MATCH '&#94;one'              <i>-- first token in any column must be "one"</i>
  ... MATCH '&#94; one + two'       <i>-- phrase "one two" must appear at start of a column</i>
  ... MATCH '&#94; "one two"'       <i>-- same as previous </i>
  ... MATCH 'a : &#94;two'          <i>-- first token of column "a" must be "two"</i>
  ... MATCH 'NEAR(&#94;one, two)'   <b>-- syntax error! </b>
  ... MATCH 'one + &#94;two'        <b>-- syntax error! </b>
  ... MATCH '"&#94;one two"'        <b>-- May not work as expected!</b>
</codeblock>

<h2 tags="FTS5 NEAR queries">FTS5 NEAR Queries</h2>

<p>Two or more phrases may be grouped into a <b>NEAR group</b>. A NEAR group
is specified by the token "NEAR" (case sensitive) followed by an open
parenthesis character, followed by two or more whitespace separated phrases, optionally followed by a comma and the numeric parameter <i>N</i>, followed by
a close parenthesis. For example: