FullTextIndex
Defined in: libs/runtime/src/full-text.ts:85
Full-text search over a store’s things, in SQLite’s FTS5. It is kept current by the change log as things are written, and
reached through db.changeLog.fullText.
Member summary
Section titled “Member summary”Constructors
| Name | Description |
|---|---|
| new FullTextIndex() | Opens the index over a database. |
Methods
| Name | Description |
|---|---|
| count() | How many things are indexed. |
| ensureSchema() | Creates the index’s tables if they do not exist. |
| index() | Index an entity’s current state, replacing whatever was there. |
| remove() | Removes a thing from the index. |
| search() | Search, using FTS5’s own query syntax. |
| assertAvailable() | Throws with a usable message if this SQLite lacks FTS5, rather than failing obscurely later. |
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new FullTextIndex(
db):FullTextIndex
Defined in: libs/runtime/src/full-text.ts:91
Opens the index over a database. It creates nothing until ensureSchema.
Parameters
Section titled “Parameters”The database that holds the index.
Returns
Section titled “Returns”FullTextIndex
Methods
Section titled “Methods”count()
Section titled “count()”count():
number
Defined in: libs/runtime/src/full-text.ts:220
How many things are indexed.
Returns
Section titled “Returns”number
ensureSchema()
Section titled “ensureSchema()”ensureSchema():
void
Defined in: libs/runtime/src/full-text.ts:123
Creates the index’s tables if they do not exist.
Returns
Section titled “Returns”void
Throws
Section titled “Throws”if this SQLite has no FTS5.
index()
Section titled “index()”index(
entityId,state):void
Defined in: libs/runtime/src/full-text.ts:135
Index an entity’s current state, replacing whatever was there.
Called from projection, inside the same transaction as the data — an index updated afterwards can disagree with the store if the process dies between the two, and a search index that silently lags is worse than one that is obviously absent.
Parameters
Section titled “Parameters”entityId
Section titled “entityId”string
Returns
Section titled “Returns”void
remove()
Section titled “remove()”remove(
entityId):void
Defined in: libs/runtime/src/full-text.ts:159
Removes a thing from the index. Does nothing if it is not there.
Parameters
Section titled “Parameters”entityId
Section titled “entityId”string
Returns
Section titled “Returns”void
search()
Section titled “search()”search(
query,limit?): readonlySearchHit[]
Defined in: libs/runtime/src/full-text.ts:208
Search, using FTS5’s own query syntax.
Column filters are written doctype:adr. Prefix is term*. Lucene’s fuzzy (~), boost (^) and
range syntax have no equivalent: a query using them is a caller error here, not a silent empty answer.
Parameters
Section titled “Parameters”string
limit?
Section titled “limit?”number = 50
Returns
Section titled “Returns”readonly SearchHit[]
assertAvailable()
Section titled “assertAvailable()”
staticassertAvailable(db):void
Defined in: libs/runtime/src/full-text.ts:105
Throws with a usable message if this SQLite lacks FTS5, rather than failing obscurely later.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
TypeDBLite is an independent open-source project, built on TypeDB with thanks. It is not affiliated with, sponsored by, or endorsed by TypeDB Ltd. Released under the MPL-2.0 license.