prorm API Reference
    Preparing search index...

    Class ElasticsearchStore

    ElasticsearchStore wraps the official @elastic/elasticsearch v9 client and exposes index management, document CRUD (single + bulk), Query-DSL search, and alias management as a typed, promise-based API.

    Implements

    Index
    name: "elasticsearch" = 'elasticsearch'

    The name of the store (e.g. 'mongodb', 'redis', 'dynamodb')

    library: "@elastic/elasticsearch" = '@elastic/elasticsearch'

    The client library being used

    • Delete an index. Resolves without error if the index doesn't exist.

      Parameters

      • index: string

      Returns Promise<void>

    • Whether an index exists.

      Parameters

      • index: string

      Returns Promise<boolean>

    • Get the field mappings for an index.

      Parameters

      • index: string

      Returns Promise<MappingTypeMapping | undefined>

    • Add/update field mappings on an existing index. Mapping updates are additive - existing field mappings cannot be changed, only new fields added.

      Parameters

      • index: string
      • mappings: MappingTypeMapping

      Returns Promise<void>

    • Get an index's settings.

      Parameters

      • index: string

      Returns Promise<IndicesIndexSettings | undefined>

    • Update dynamic index settings (e.g. number_of_replicas, refresh_interval). Static settings like number_of_shards require closing the index first (not wrapped here - use getClient()).

      Parameters

      • index: string
      • settings: IndicesIndexSettings

      Returns Promise<void>

    • Refresh an index so recently-written documents become visible to search immediately, rather than waiting for the automatic refresh interval.

      Parameters

      • index: string

      Returns Promise<void>

    • Index (create or overwrite) a document. Omit id to let Elasticsearch auto-generate one. Returns the assigned _id.

      Parameters

      • index: string
      • document: Record<string, unknown>
      • options: IndexDocumentOptions & { id?: string } = {}

      Returns Promise<string>

    • Get a document by ID. Returns null if it doesn't exist.

      Type Parameters

      • T = Record<string, unknown>

      Parameters

      • index: string
      • id: string

      Returns Promise<T | null>

    • Whether a document exists.

      Parameters

      • index: string
      • id: string

      Returns Promise<boolean>

    • Partially update a document by merging partial into the stored _source. Pass options.upsert to insert that document if id doesn't already exist yet. Throws EmptyResultError if the document doesn't exist and no upsert was provided.

      Parameters

      Returns Promise<void>

    • Delete a document by ID. Returns true if a document was deleted, false if it didn't exist (rather than throwing, since "already gone" is a common, non-exceptional outcome for a delete).

      Parameters

      Returns Promise<boolean>

    • Run a batch of index/create/update/delete operations in a single request. Unlike a SQL transaction, this is not atomic - each item succeeds or fails independently; check result.errors and each item's error field rather than assuming all-or-nothing.

      Parameters

      Returns Promise<BulkResult>

    • Convenience wrapper around bulk() for indexing many documents into one index at once.

      Parameters

      • index: string
      • documents: { id?: string; document: Record<string, unknown> }[]

      Returns Promise<BulkResult>

    • Run a Query DSL search (match/term/bool/range/etc.) against one or more indices (comma-separated, or a wildcard pattern). Supports from/size pagination, sort, and named aggs.

      Type Parameters

      • T = Record<string, unknown>

      Parameters

      Returns Promise<SearchResult<T>>

    • Count documents matching a query (or all documents, if query is omitted) without fetching them.

      Parameters

      • index: string
      • Optionalquery: QueryDslQueryContainer

      Returns Promise<number>

    • Point an alias at an index, creating the alias if it doesn't exist.

      Parameters

      • index: string
      • alias: string

      Returns Promise<void>

    • Remove an alias from an index.

      Parameters

      • index: string
      • alias: string

      Returns Promise<void>

    • List the indices an alias currently points at.

      Parameters

      • alias: string

      Returns Promise<string[]>

    • Atomically repoint an alias from one index to another - the standard zero-downtime reindex pattern (build the new index, then swap the alias in one request so readers never see a moment with no index behind the alias).

      Parameters

      • alias: string
      • fromIndex: string
      • toIndex: string

      Returns Promise<void>