`pelias-dbclient` is a core Node.js module within the Pelias geocoder ecosystem, providing a stream-based interface for efficiently bulk-inserting documents into Elasticsearch. Its primary function is to act as a crucial pipeline stage for Pelias import processes, transforming Pelias `Document` objects into Elasticsearch-compatible bulk operations. The current stable version is v3.3.0, with releases occurring on a feature-driven, rather than strict time-based, cadence, though a major version (v3.0.0) was released in March 2024. Key differentiators include its tight integration with the Pelias data model, its focus on streaming for large-scale data ingestion, and its commitment to open-source principles as part of the broader Pelias open-data geocoding project. It leverages the official `elasticsearch` client under the hood and is designed specifically for Node.js environments.
npm install pelias-dbclientVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `pelias-dbclient` as a transform stream to bulk-insert Pelias Document objects into Elasticsearch, followed by a cleanup operation upon stream completion. It shows the typical integration within a Pelias import pipeline.
Ensure your Elasticsearch cluster is running v7 or v8. Update any Pelias configuration or custom data models that explicitly rely on or set the `_type` field, as it is deprecated in newer Elasticsearch versions.
Upgrade your Node.js environment to version 10.0.0 or higher to ensure compatibility and leverage modern JavaScript features and security updates.
When chaining operations or performing post-import tasks, always listen for the 'finish' event on the `dbclient` stream to ensure all data has been written to Elasticsearch.
Ensure that your `pelias-config` module is properly set up and configured for your environment, specifically the `esclient` and `schema.indexName` properties, before initializing `pelias-dbclient`.
Verify your Pelias configuration files (`pelias.json` or environment variables) are correctly set up and accessible to the application. Ensure `pelias-config` can locate and parse them.
Update your Pelias data models, import scripts, or any custom code to remove references to the `_type` field. Ensure `pelias-dbclient` is version 3.x or higher and your Elasticsearch is v7+.
Use `const dbclient = require('pelias-dbclient');` for CommonJS or `import dbclient from 'pelias-dbclient';` for ESM. Do not use `{ dbclient }`.Upgrade your Node.js environment to version 10.0.0 or higher. The recommended version for current `pelias-dbclient` releases is Node.js 16 or newer.