FTS3Pattern

public struct FTS3Pattern
extension FTS3Pattern: DatabaseValueConvertible

A full text pattern that can query FTS3 and FTS4 virtual tables.

  • The raw pattern string. Guaranteed to be a valid FTS3/4 pattern.

    Declaration

    Swift

    public let rawPattern: String
  • Creates a pattern from a raw pattern string; throws DatabaseError on invalid syntax.

    The pattern syntax is documented at https://www.sqlite.org/fts3.html#full_text_index_queries

    try FTS3Pattern(rawPattern: "and") // OK
    try FTS3Pattern(rawPattern: "AND") // malformed MATCH expression: [AND]
    

    Declaration

    Swift

    public init(rawPattern: String) throws
  • Creates a pattern that matches any token found in the input string; returns nil if no pattern could be built.

    FTS3Pattern(matchingAnyTokenIn: "")        // nil
    FTS3Pattern(matchingAnyTokenIn: "foo bar") // foo OR bar
    

    Declaration

    Swift

    public init?(matchingAnyTokenIn string: String)

    Parameters

    string

    The string to turn into an FTS3 pattern

  • Creates a pattern that matches all tokens found in the input string; returns nil if no pattern could be built.

    FTS3Pattern(matchingAllTokensIn: "")        // nil
    FTS3Pattern(matchingAllTokensIn: "foo bar") // foo bar
    

    Declaration

    Swift

    public init?(matchingAllTokensIn string: String)

    Parameters

    string

    The string to turn into an FTS3 pattern

  • Creates a pattern that matches all token prefixes found in the input string; returns nil if no pattern could be built.

    FTS3Pattern(matchingAllTokensIn: "")        // nil
    FTS3Pattern(matchingAllTokensIn: "foo bar") // foo* bar*
    

    Declaration

    Swift

    public init?(matchingAllPrefixesIn string: String)

    Parameters

    string

    The string to turn into an FTS3 pattern

  • Creates a pattern that matches a contiguous string; returns nil if no pattern could be built.

    FTS3Pattern(matchingPhrase: "")        // nil
    FTS3Pattern(matchingPhrase: "foo bar") // "foo bar"
    

    Declaration

    Swift

    public init?(matchingPhrase string: String)

    Parameters

    string

    The string to turn into an FTS3 pattern

  • Returns a value that can be stored in the database.

    Declaration

    Swift

    public var databaseValue: DatabaseValue { get }
  • Returns an FTS3Pattern initialized from dbValue, if it contains a suitable value.

    Declaration

    Swift

    public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> FTS3Pattern?