This class is responsible for indexing all documents available in the world and storing them in a word tree structure that allows for fast searching.

Properties

#ready: Promise<void> = null

While we are indexing, we store a Promise that resolves when the indexing is complete.

Accessors

  • get ready(): Promise<void>
  • Returns a Promise that resolves when the indexing process is complete.

    Returns Promise<void>

Methods

  • Index all available documents in the world and store them in a word tree.

    Returns Promise<void>

  • Return entries that match the given string prefix.

    Parameters

    • prefix: string

      The prefix.

    • Optional options: {
          documentTypes: string[];
          limit: number;
          filterEntries: StringTreeEntryFilter;
          ownership: any;
      } = {}

      Additional options to configure behaviour.

      • documentTypes: string[]

        Optionally provide an array of document types. Only entries of that type will be searched for.

      • limit: number

        The maximum number of items per document type to retrieve. It is important to set this value as very short prefixes will naturally match large numbers of entries.

      • filterEntries: StringTreeEntryFilter

        A filter function to apply to each candidate entry.

      • ownership: any

        Only return entries that the user meets this ownership level for.

    Returns Record<string, WordTreeEntry[]>

    A number of entries that have the given prefix, grouped by document type.

  • Add an entry to the index.

    Parameters

    • doc: Document

      The document entry.

    Returns void

  • Remove an entry from the index.

    Parameters

    • doc: Document

      The document entry.

    Returns void

  • Replace an entry in the index with an updated one.

    Parameters

    • doc: Document

      The document entry.

    Returns void

  • Protected

    Add a leaf node to the word tree index.

    Parameters

    • doc: object | Document

      The document or compendium index entry to add.

    • Optional options: {
          pack: CompendiumCollection;
      } = {}

      Additional information for indexing.

    Returns void

  • Protected

    Aggregate the compendium index and add it to the word tree index.

    Parameters

    Returns void

  • Protected

    Add all of a parent document's embedded documents to the index.

    Parameters

    • parent: Document

      The parent document.

    Returns void

  • Protected

    Aggregate all documents and embedded documents in a world collection and add them to the index.

    Parameters

    • documentName: string

      The name of the documents to index.

    Returns void

  • Check if the given entry meets the given ownership requirements.

    Parameters

    • entry: WordTreeEntry

      The candidate entry.

    • ownership: any

      The ownership.

    Returns boolean