Elastic-builder is a JavaScript library designed to construct Elasticsearch Query DSL (Domain Specific Language) bodies using a fluent builder pattern, making complex queries easier to write and maintain. Currently in stable version 4.1.0, the package sees a consistent release cadence, with updates typically occurring every 1-2 months to introduce new features and maintain compatibility with modern Node.js versions. Its key differentiators include comprehensive TypeScript definitions for an enhanced development experience, compatibility with the official Elasticsearch JavaScript client, and a focus on replicating Elasticsearch 5.x DSL (while largely usable with newer versions). It provides both class-based and functional builder utilities (e.g., `new esb.MatchQuery()` vs. `esb.matchQuery()`) and recently removed `lodash` as a dependency in v4.1.0, reducing its footprint.
npm install elastic-builderVerified import paths — ran on the pinned version, not inferred.
Demonstrates building a complex Elasticsearch query body using a boolean query, range filter, terms aggregation, and sorting, then outputs the JSON representation.
Upgrade your Node.js environment to version 20.x, 22.x, or 24.x LTS to ensure compatibility and correct execution.
Consult the official Elasticsearch documentation for your specific target version and cross-reference with `elastic-builder`'s API reference. For advanced or highly version-specific features, you might need to construct parts of the query JSON manually.
For ESM, use `import * as esb from 'elastic-builder';` to import all named exports as a single object. For CommonJS environments, `const esb = require('elastic-builder');` remains the correct pattern.Change your import statement from `import esb from 'elastic-builder';` to `import * as esb from 'elastic-builder';` in ESM files.
Ensure `elastic-builder` is installed in your project (`npm install elastic-builder`) and verify that your Node.js runtime is version 20.x, 22.x, or 24.x LTS. Upgrade Node.js if necessary.
No dependency data recorded yet.