Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External Content FTS4 Table #164

Closed
go1t opened this issue Jul 29, 2015 · 3 comments
Closed

External Content FTS4 Table #164

go1t opened this issue Jul 29, 2015 · 3 comments

Comments

@go1t
Copy link

go1t commented Jul 29, 2015

Is there a way to do this in SQLite.swift? :

 CREATE VIRTUAL TABLE table USING fts4(content='some_other_table', id, name)

I'd like to pre-populate my fts4 virtual table, but inserting one by one is very slow since my table contains over 30,000 rows. Is there any recommended way for this in SQLite.swift?

@stephencelis
Copy link
Owner

Many of the options for fts4 aren't exposed yet but should be. In the meantime, aking this function public will get you closer:

private func fts(function: String, columns: [Expression<String>], options: [String: String]) -> Expression<Void> {

Or you can execute the raw SQL instead.

@lukescott
Copy link
Contributor

It would also be nice if there was a way to setup the triggers to keep the data in sync, such as:

CREATE TABLE t2(id INTEGER PRIMARY KEY, a, b, c);
CREATE VIRTUAL TABLE t3 USING fts4(content="t2", a, c);
CREATE TRIGGER t2_bu BEFORE UPDATE ON t2 BEGIN
  DELETE FROM t3 WHERE docid=old.rowid;
END;
CREATE TRIGGER t2_bd BEFORE DELETE ON t2 BEGIN
  DELETE FROM t3 WHERE docid=old.rowid;
END;
CREATE TRIGGER t2_au AFTER UPDATE ON t2 BEGIN
  INSERT INTO t3(docid, b, c) VALUES(new.rowid, new.b, new.c);
END;
CREATE TRIGGER t2_ai AFTER INSERT ON t2 BEGIN
  INSERT INTO t3(docid, b, c) VALUES(new.rowid, new.b, new.c);
END;

http://www.sqlite.org/fts3.html#section_6_2_2

@mikemee
Copy link
Collaborator

mikemee commented Jan 11, 2016

Added to Feature Requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants