RelationTextIndex

public class RelationTextIndex

An index for fast full-text searches of large quantities of text. Manages two Relations which provide the text and related info, and provides Relations which provide search results.

  • Undocumented

    See more

    Declaration

    Swift

    public enum Error : RelationError
  • Initialize a new index object.

    Throws

    SQLiteDatabase.Error if something went wrong with SQLite setup.

    Declaration

    Swift

    public init(ids: (Relation, Attribute), content: (Relation, Attribute), columnConfigs: [ColumnConfig]) throws

    Parameters

    ids

    A Relation which provides page IDs, and the attribute for the IDs. This is used to get the initial list of pages.

    content

    A Relation which provides page content and IDs, plus the attribute for the IDs.

    contentTextExtractor

    A function which, given a Row from the content Relation, returns the text that row contains.

  • Return a Relation which contains matches for the given query.

    Declaration

    Swift

    public func search(_ query: String) -> SearchRelation

    Parameters

    query

    The query, using SQLite FTS4 syntax.

    Return Value

    A Relation containing the IDs of matching entries. It contains only IDs, under the ID attribute provided for the content relation passed into init. It can be renamed/joined with other tables if more information is desired.

  • A Relation which holds search results from an index. The scheme is a single attribute: the contentIDAttribute which was passed in to the index. The Relation’s contents update asynchronously when the search query is changed.

    See more

    Declaration

    Swift

    public class SearchRelation : MemoryTableRelation
  • Undocumented

    Declaration

    Swift

    public static let matchStartCharacter: UnicodeScalar
  • Undocumented

    Declaration

    Swift

    public static let matchEndCharacter: UnicodeScalar
  • Undocumented

    Declaration

    Swift

    public static let ellipsesCharacter: UnicodeScalar
  • A structured representation of a snippet. Initialize it with the raw string from a snippet column of a SearchRelation, and it will read the special characters embedded in the snippet string and transform them into this structured representation.

    See more

    Declaration

    Swift

    public struct StructuredSnippet : Hashable
  • Configuration for a column of searchable text.

    See more

    Declaration

    Swift

    public struct ColumnConfig