Use full-text search for SQLite tables in Android

Source: Internet
Author: User
In Android, SQLite is used, and full-text retrieval is also supported. Because SQLite supports the FTS table (full-text search for short), For details, refer:

Http://www.sqlite.org/fts3.html#section_1, here we introduce the difference between fts3 and fts4,

Here, fts3 is actually an extension module of SQLite. It is a virtual table module that allows users to perform full-text retrieval. The following is a simple example:

Create virtual table enrondata1 using fts3 (content text );

You can see that an fts3 table is created using the above syntax. During retrieval, as described in the Manual:

Select count (*) from enrondata1 where content match 'linux ';/* 0.03 seconds */

Select count (*) from enrondata2 where content like '% Linux %';/* 22.5 seconds */

See? Match is used here, rather than the traditional like, and the efficiency is very high.

The following syntax is also supported:

Select * From words_fts where words_fts match 'description: company ';

Column name: the keyword to be searched for in this column.

You can also do this:

Select * From words_fts where words_fts match 'description: comp *'

Wildcard characters are supported.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.