SQLite全文搜索目录 [英] SQLite full text search catalog

查看:180
本文介绍了SQLite全文搜索目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道以下是否可能与fts(3/4)的SQLite。
我使用fts3创建了一个包含一些数据的表。



如果我例如搜索e *,我会得到以^ e
开头的所有内容我还可以搜索索引/目录中以e开头的特定单词吗?

因此,我只能得到那些单词的结果; elliot,elo,eehh。

解决方案

FTS引擎通过 偏移 虚函数。

  SELECT抵消(docs)FROM docs WHERE docs MATCH'e *'; 

正如文档所述:


对于使用全文索引的SELECT查询,offset()函数会返回包含一系列空格分隔整数的文本值。对于当前行的每个词组匹配中的每个词,返回列表中有四个整数。每一组四个整数的解释如下:


  1. 实例出现的列号(0表示FTS最左边一列表格1,下一个最左边的1等)。

  2. 全文查询表达式中匹配项的数字。查询表达式中的术语按其出现的顺序从0开始编号。

  3. 列中匹配项的字节偏移量。
  4. 匹配项的大小(以字节为单位)。


如何提取这些信息取决于您你如何将你的代码与SQLite集成。


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 starts with ^e But can i also search the index/catalog for the specific words that starts with e?

So that i only get the results of that words back like; elliot, elo,eehh.

解决方案

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.

这篇关于SQLite全文搜索目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆