Function vacuum

  • Triggers a manual vacuuming, cleaning up references to discarded documents from the inverted index

    Vacuuming is only useful for applications that use the discard or replace methods.

    By default, vacuuming is performed automatically when needed (controlled by the autoVacuum field in SearchOptions), so there is usually no need to call this method, unless one wants to make sure to perform vacuuming at a specific moment.

    Vacuuming traverses all terms in the inverted index in batches, and cleans up references to discarded documents from the posting list, allowing memory to be released.

    The method takes an optional object as argument with the following keys:

    • batchSize: the size of each batch (1000 by default)

    • batchWait: the number of milliseconds to wait between batches (10 by default)

    On large indexes, vacuuming could have a non-negligible cost: batching avoids blocking the thread for long, diluting this cost so that it is not negatively affecting the application. Nonetheless, this method should only be called when necessary, and relying on automatic vacuuming is usually better.

    It returns a promise that resolves (to undefined) when the clean up is completed. If vacuuming is already ongoing at the time this method is called, a new one is enqueued immediately after the ongoing one, and a corresponding promise is returned. However, no more than one vacuuming is enqueued on top of the ongoing one, even if this method is called more times (enqueuing multiple ones would be useless).

    Type Parameters

    • Document

    • ID

    Parameters

    Returns Promise<void>

Generated using TypeDoc