Foundry Virtual Tabletop - API Documentation - Version 14
    Preparing search index...

    Class DocumentIndex

    This class is responsible for indexing all documents available in the world. Stores documents using a word tree structure that allows for efficient searching.

    Index

    Accessors

    • get ready(): Promise<void> | null

      Returns a Promise that resolves when the indexing process is complete.

      Returns Promise<void> | null

    Methods

    • Add an entry to the index.

      Parameters

      • doc: Document

        The document entry.

      Returns void

    • 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.

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

        Additional options to configure behaviour.

        • OptionaldocumentTypes?: string[]

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

        • OptionalfilterEntries?: StringTreeEntryFilter

          A filter function to apply to each candidate entry.

        • Optionallimit?: 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.

        • Optionalownership?: 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.

    • 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.

      • Optionaloptions: { pack?: any } = {}

        Additional information for indexing.

        • Optionalpack?: any

          The compendium that the index belongs to.

      Returns void

    • Protected

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

      Parameters

      • pack: CompendiumCollection

        The compendium pack.

      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