Fts4
@Target([AnnotationTarget.CLASS, AnnotationTarget.FILE]) @RequiresApi(16) class Fts4
androidx.room.Fts4 |
Marks an Entity
annotated class as a FTS4 entity. This class will have a mapping SQLite FTS4 table in the database.
FTS3 and FTS4 are SQLite virtual table modules that allows full-text searches to be performed on a set of documents.
An FTS entity table always has a column named rowid
that is the equivalent of an INTEGER PRIMARY KEY
index. Therefore, an FTS entity can only have a single field annotated with PrimaryKey
, it must be named rowid
and must be of INTEGER
affinity. The field can be optionally omitted in the class but can still be used in queries.
All fields in an FTS entity are of TEXT
affinity, except the for the 'rowid' and 'languageid' fields.
Example:
@Entity @Fts4 public class Mail { @PrimaryKey @ColumnInfo(name = "rowid") private final int rowId; private final String subject; private final String body; public Mail(int rowId, String subject, String body) { this.rowId = rowId; this.subject = subject; this.body = body; } public String getRowId() { return rowId; } public String getSubject() { return subject; } public void getBody() { return body; } }
Summary
Public constructors | |
---|---|
<init>(tokenizer: String, tokenizerArgs: Array<String>, contentEntity: KClass<*>, languageId: String, matchInfo: FtsOptions.MatchInfo, notIndexed: Array<String>, prefix: IntArray, order: FtsOptions.Order) Marks an |
Properties | |
---|---|
KClass<*> |
The external content entity who's mapping table will be used as content for the FTS table. |
String |
The column name to be used as 'languageid'. |
FtsOptions.MatchInfo |
The FTS version used to store text matching information. |
Array<String> |
The list of column names on the FTS table that won't be indexed. |
FtsOptions.Order |
The preferred 'rowid' order of the FTS table. |
IntArray |
The list of prefix sizes to index. |
String |
The tokenizer to be used in the FTS table. |
Array<String> |
Optional arguments to configure the defined tokenizer. |
Public constructors
<init>
Fts4(
tokenizer: String,
tokenizerArgs: Array<String>,
contentEntity: KClass<*>,
languageId: String,
matchInfo: FtsOptions.MatchInfo,
notIndexed: Array<String>,
prefix: IntArray,
order: FtsOptions.Order)
Marks an Entity
annotated class as a FTS4 entity. This class will have a mapping SQLite FTS4 table in the database.
FTS3 and FTS4 are SQLite virtual table modules that allows full-text searches to be performed on a set of documents.
An FTS entity table always has a column named rowid
that is the equivalent of an INTEGER PRIMARY KEY
index. Therefore, an FTS entity can only have a single field annotated with PrimaryKey
, it must be named rowid
and must be of INTEGER
affinity. The field can be optionally omitted in the class but can still be used in queries.
All fields in an FTS entity are of TEXT
affinity, except the for the 'rowid' and 'languageid' fields.
Example:
@Entity @Fts4 public class Mail { @PrimaryKey @ColumnInfo(name = "rowid") private final int rowId; private final String subject; private final String body; public Mail(int rowId, String subject, String body) { this.rowId = rowId; this.subject = subject; this.body = body; } public String getRowId() { return rowId; } public String getSubject() { return subject; } public void getBody() { return body; } }
See Also
Properties
contentEntity
val contentEntity: KClass<*>
The external content entity who's mapping table will be used as content for the FTS table.
Declaring this value makes the mapping FTS table of this entity operate in "external content" mode. In such mode the FTS table does not store its own content but instead uses the data in the entity mapped table defined in this value. This option allows FTS4 to forego storing the text being indexed which can be used to achieve significant space savings.
In "external mode" the content table and the FTS table need to be synced. Room will create the necessary triggers to keep the tables in sync. Therefore, all write operations should be performed against the content entity table and not the FTS table.
The content sync triggers created by Room will be removed before migrations are executed and are re-created once migrations are complete. This prevents the triggers from interfering with migrations but means that if data needs to be migrated then write operations might need to be done in both the FTS and content tables.
Return | |
---|---|
KClass<*> |
The external content entity. |
See Also
languageId
val languageId: String
The column name to be used as 'languageid'.
Allows the FTS4 extension to use the defined column