Registry / database / elasticsearch-store

elasticsearch-store

JSON →
library2.11.1jsnpmunverified

elasticsearch-store (v2.11.1) is a TypeScript library for managing Elasticsearch indices with versioning and migration support. It provides a structured API to create, update, and migrate indices, ensuring schema evolution over time. Released under the Terascope organization, it targets Node.js >=22 and pnpm >=11.3. Key differentiators include built-in migration handling, type-safe index management, and integration with the Teraslice ecosystem. Maintained actively with a focus on reliability.

npm install elasticsearch-store
INSTALL
IMPORT
SIG · ELASTICSEARCH-STOR
E
elasticsearch-store
databasejavascriptv2.11.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

IndexStore
import { IndexStore } from 'elasticsearch-store'
const IndexStore = require('elasticsearch-store')
ESM-only since v2. Default export not available.
Migration
import { Migration } from 'elasticsearch-store'
import Migration from 'elasticsearch-store'
Named export, not default.
StoreConfig
import type { StoreConfig } from 'elasticsearch-store'
import { StoreConfig } from 'elasticsearch-store'
Use type import for TypeScript interfaces.

Initializes an IndexStore with client, defines mapping and version, creates index, indexes a document, and retrieves it.

import { Client } from '@elastic/elasticsearch'; import { IndexStore } from 'elasticsearch-store'; async function main() { const client = new Client({ node: process.env.ELASTICSEARCH_URL ?? 'http://localhost:9200' }); const store = new IndexStore(client, { name: 'my-index', version: 1, mappings: { properties: { name: { type: 'text' }, age: { type: 'integer' } } } }); await store.initialize(); await store.indexDocument({ name: 'John', age: 30 }); const doc = await store.getDocument('some-id'); console.log(doc); } main().catch(console.error);
Debug
Known issues
breakingRequires Node.js >=22.0.0 and pnpm >=11.3.0. Older versions are not supported.
fix
Upgrade Node.js to v22+ and pnpm to v11.3+.
affects: >=2.0.0
gotchaIndex migrations must be explicitly applied after initialization.
fix
Ensure to call `store.migrate()` after `store.initialize()` if migrations are defined.
affects: >=1.0.0
deprecatedThe `IndexStore` constructor no longer accepts `client` as second argument in v2. Use options object.
fix
Pass client inside options as `{ client }`.
affects: >=2.0.0
gotchaTypeScript strict mode may require explicit type annotations for generic methods.
fix
Use `store.indexDocument<MyType>(doc)` to ensure type safety.
affects: >=2.0.0
breakingESM-only module: CommonJS `require()` will fail.
fix
Use `import` syntax or dynamic `import()`.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: client.helpers.bulk is not a function
Incorrect @elastic/elasticsearch version (v7 vs v8 API change)
fix
Install @elastic/elasticsearch@8 or higher.
Error: No index mappings provided
Missing `mappings` option in IndexStore constructor
fix
Add `mappings: { properties: {...} }` to configuration.
ERR_REQUIRE_ESM: require() of ES Module not supported
Using CommonJS require() on ESM-only package
fix
Change to import statement or use dynamic import().
Upgrade
Version history
2.11.1latest on npm
Audit
Dependencies
@elastic/elasticsearchrequiredOfficial Elasticsearch client for Node.js
Agent activity
7 hits · last 30 days
node
6
Resources