On Fri, Dec 31, 2010 at 8:47 AM, Black, Michael (IS) <michael.bla...@ngc.com
> wrote:

> (I have to remember to take of this stupid EXTERNAL thing my emailer puts
> on all outside emails...)
>
> Actually, this is the way I understand it right now...
>
> Construct: MATCH 'bug report API_Version:374 OR API_Version:UAR'
>
> Verbose: Perform an FTS search on the order-independent AND'd words 'bug
> report API Version 376' OR 'API Version UAR', and return only
> records that contain either grouping.
>

This is true if and only if you compiled using
SQLITE_ENABLE_FTS3_PARENTHESIS.  The legacy behavior (and the behavior
matching popular search engines) that is used when the above compile-time
option is omitted is that OR has higher precedence than AND.  Hence, the
query is equivalent to:

      MATCH 'bug report (api_version:374 OR api_version:uar)'

Note that the example above is notional only.  Parentheses cannot be used
for grouping in the legacy query syntax.  But if you do define the
SQLITE_ENABLE_FTS3_PARENTHESIS compile-time option, then AND gets higher
precedence than OR and the query becomes:

     MATCH '(bug report api_version:374) OR (api_version:uar)'

In both cases, the "api_version:" prefix on "374" and "uar" means that the
tokens "374" and "uar" much appear in the "api_version" column of the FTS
table.


>
> Let's confirm adding on to our last example...
>
> sqlite> insert into data values('UAR report bug 374 API_Version');
> sqlite> select * from data where content match  'bug report API_Version:374
> OR API_Version:UAR';
> we got bug report API_Version:374 is right here
> we got API_Version:UAR right here
> UAR report bug 374 API_Version
>
> There's no order dependence at all...
>
> Quotes around the 2nd phrase makes no difference.
> sqlite> select * from data where content match  'bug report API_Version:374
> OR "API_Version:UAR"';
> we got bug report API_Version:374 is right here
> we got API_Version:UAR right here
> UAR report bug 374 API_Version
>
> Quotes around the 1st phrase does make a difference:
> sqlite> select * from data where content match  '"bug report
> API_Version:374" OR "API_Version:UAR"';
> we got bug report API_Version:374 is right here
> we got API_Version:UAR right here
>
> So I'm completely confused as to what quotes do here...
>
>
> Michael D. Black
> Senior Scientist
> Advanced Analytics Directorate
> Northrop Grumman Information Systems
>
>
> ________________________________
>
> From: sqlite-users-boun...@sqlite.org on behalf of Tod Wulff
> Sent: Wed 12/29/2010 12:06 PM
> To: 'General Discussion of SQLite Database'
> Subject: EXTERNAL:Re: [sqlite] FTS4 snippets contains unintended content?
>
>
>
> Good day, Michael.  Thank you for taking the time to respond.
>
> Per my (possibly ignorant) understanding of the FTS docs, this construct
> can
> be described as such:
>
> Construct: MATCH 'bug report API_Version:374 OR API_Version:UAR'
>
> Verbose: Perform an FTS search on the phrase 'bug report', and return only
> records that contain '374' or 'UAR' in the API_Version column.
>
>
>
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>


-- 
D. Richard Hipp
d...@sqlite.org
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to