Registry / database / pelias-schema

pelias-schema

JSON →
library9.1.0jsnpmunverified

Elasticsearch schema definitions and tooling for the Pelias geocoder. As of v9.1.0, this package provides the Elasticsearch index mappings, settings, and scripts to create, drop, and update indices required by Pelias. It is updated alongside Pelias releases to support latest Elasticsearch versions (compatible with ES 7.x). Key differentiators: ships with pre-tuned analyzers and filters optimized for geocoding (e.g., custom synonym files), and integrates with pelias-config for dynamic index name. Release cadence is tied to Pelias core releases, approximately quarterly.

npm install pelias-schema
INSTALL
IMPORT
SIG · PELIAS-SCHEMA
P
pelias-schema
databasejavascriptv9.1.0
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.

createIndex
✓ const { createIndex } = require('pelias-schema');
✗ import { createIndex } from 'pelias-schema';
This package is CJS-only and does not ship ESM. Use require() only.
dropIndex
✓ const { dropIndex } = require('pelias-schema');
dropIndex prompts for confirmation by default. Use --force-yes flag to skip.
schema
✓ const { schema } = require('pelias-schema');
✗ const schema = require('pelias-schema');
The default export is an object with multiple methods; schema is a named export containing the Elasticsearch mappings object.

Shows how to require and use the main functions: createIndex with an Elasticsearch client, dropIndex, and access the schema object.

const { createIndex, dropIndex, schema } = require('pelias-schema'); // Create the default Pelias index in Elasticsearch createIndex({ client: require('elasticsearch').Client({ host: 'http://localhost:9200' }) }, (err, resp) => { if (err) console.error(err); else console.log('Index created:', resp); }); // Drop the index with confirmation prompt // dropIndex({ client: elasticsearchClient }); // Log the schema mapping console.log(JSON.stringify(schema, null, 2));
Debug
Known issues
breakingv7+ drops support for Elasticsearch 6.x. The schema is now only compatible with Elasticsearch 7.
fix
Upgrade your Elasticsearch cluster to version 7.x before updating pelias-schema to v7+.
affects: >=7.0.0
deprecatedv9.0.0 removed the 'updateSettings' function; use scripts/update_settings.js directly.
fix
Instead of calling the exported updateSettings, run node scripts/update_settings.js from the package root.
affects: >=9.0.0
gotchaThe schema.indexName from pelias-config is only read once at creation; changing it after index creation has no effect.
fix
Ensure the index name is correctly set in pelias.json before creating the index. If you need to rename, create a new index and reimport data.
affects: >=1.0.0
gotchaRunning dropIndex without --force-yes prompts for confirmation via stdin; in non-interactive environments it will hang.
fix
Always pass --force-yes flag when running in scripts or CI: node scripts/drop_index.js --force-yes
affects: >=1.0.0
gotchaThe number_of_shards cannot be changed after index creation. The default is 5; plan ahead.
fix
Set desired number_of_shards in pelias.json via schema.settings.index.number_of_shards before creating the index.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'pelias-config'
The pelias-schema package requires pelias-config as a peer dependency but it is not installed.
fix
Run: npm install pelias-config
TypeError: client.indices.create is not a function
You passed an Elasticsearch client that does not have the indices namespace (e.g., wrong version or incomplete mock).
fix
Ensure you create a valid Elasticsearch client: require('elasticsearch').Client({ host: 'localhost:9200' })
Error: No Living connections
Elasticsearch server is not running or the host/port is incorrect.
fix
Start Elasticsearch on localhost:9200 or update host in client configuration.
RequestTimeout: Request timed out after 30000ms
Elasticsearch is slow or unresponsive, or the index creation takes too long.
fix
Increase client requestTimeout (e.g., new Client({ requestTimeout: 120000 })) or check Elasticsearch health.
Upgrade
Version history
9.1.0latest on npm
Audit
Dependencies
pelias-configrequiredUsed to read schema.indexName and other Pelias configuration from pelias.json
elasticsearchoptionalRequired by Elasticsearch client used in scripts; may be optional if using @elastic/elasticsearch
Agent activity
45 hits · last 30 days
node
40
OpenAI (training)
1
Resources
pelias-schema — npm install pelias-schema · libregistry