SQLite full text search catalog

前端 未结 3 847
感动是毒
感动是毒 2021-01-16 00:19

I wonder if the following is possible with fts(3/4) for SQLite. I created a table with some data using fts3.

If i for example search for e* i get everything that sta

3条回答
  •  攒了一身酷
    2021-01-16 01:07

    The FTS engine provides that information via the offsets virtual function.

    SELECT offsets(docs) FROM docs WHERE docs MATCH 'e*';
    

    As the documentation says:

    For a SELECT query that uses the full-text index, the offsets() function returns a text value containing a series of space-separated integers. For each term in each phrase match of the current row, there are four integers in the returned list. Each set of four integers is interpreted as follows:

    1. The column number that the term instance occurs in (0 for the leftmost column of the FTS table, 1 for the next leftmost, etc.).
    2. The term number of the matching term within the full-text query expression. Terms within a query expression are numbered starting from 0 in the order that they occur.
    3. The byte offset of the matching term within the column.
    4. The size of the matching term in bytes.

    How to extract that information is up to you and how you integrate your code with SQLite.

提交回复
热议问题