Fts3

@Target([AnnotationTarget.CLASS, AnnotationTarget.FILE]) class Fts3
androidx.room.Fts3

Marks an Entity annotated class as a FTS3 entity. This class will have a mapping SQLite FTS3 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' field.

Example:

@Entity
  @Fts3
  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>)

Marks an Entity annotated class as a FTS3 entity.

Properties

String

The tokenizer to be used in the FTS table.

Array<String>

Optional arguments to configure the defined tokenizer.

Public constructors

<init>

Fts3(tokenizer: String, tokenizerArgs: Array<String>)

Marks an Entity annotated class as a FTS3 entity. This class will have a mapping SQLite FTS3 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' field.

Example:

@Entity
  @Fts3
  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;
    }
  }
  

Properties

tokenizer

val tokenizer: String

The tokenizer to be used in the FTS table.

The default value is FtsOptions#TOKENIZER_SIMPLE. Tokenizer arguments can be defined with tokenizerArgs().

If a custom tokenizer is used, the tokenizer and its arguments are not verified at compile time.

Return
String: The tokenizer to use on the FTS table. Built-in available tokenizers are FtsOptions#TOKENIZER_SIMPLE, FtsOptions#TOKENIZER_PORTER and FtsOptions#TOKENIZER_UNICODE61.

See Also

  • #tokenizerArgs()<a href="https://www.sqlite.org/fts3.html#tokenizer">SQLite tokernizers

tokenizerArgs

val tokenizerArgs: Array<String>

Optional arguments to configure the defined tokenizer.

Tokenizer arguments consist of an argument name, followed by an "=" character, followed by the option value. For example, separators=. defines the dot character as an additional separator when using the FtsOptions#TOKENIZER_UNICODE61 tokenizer.

The available arguments that can be defined depend on the tokenizer defined, see the SQLite tokernizers documentation for details.

Return
Array<String>: A list of tokenizer arguments strings.