我目前有诊断表.我想使用FTS搜索代码和描述字段.据我所知,FTS表不支持索引,我需要能够非常快速地通过诊断ID查找诊断.我是否必须创建第二个虚拟表,其中所有数据都是重复的,只是为了进行全文搜索,或者我错过了一个我不需要复制所有诊断代码和描述的解决方案?
CREATE TABLE Diagnosis (
diagnosisID INTEGER PRIMARY KEY NOT NULL,
code TEXT,
collect INTEGER NOT NULL,
description TEXT
);
Run Code Online (Sandbox Code Playgroud)
结果表明FTS表有一个隐藏rowid字段,您可以在输入数据时填充该字段:
sqlite> create virtual table test1 using fts3;
sqlite> insert into test1 values ("This is a document!");
sqlite> insert into test1(docid,content) values (5,"this is another document");
sqlite> select rowid,* from test1;
1|This is a document!
5|this is another document
Run Code Online (Sandbox Code Playgroud)
您可以在标准表中创建一个整数字段,该字段通过rowid引用FTS表,并将要进行文本搜索的列移动到FTS表中.
所有的信息,你需要在这里 :)