Registry / database / esq
library1.0.3jsnpmunverified

ESQ (Elasticsearch Query) is a JavaScript library designed to simplify the construction of Elasticsearch queries by providing a programmatic API to build complex JSON query objects. Its primary function is to abstract away the repetitive object creation inherent in crafting Elasticsearch DSL, allowing developers to focus on the query logic rather than the structural boilerplate. The current stable version is 1.0.0, which was last updated in April 2016. The project appears to be abandoned, with no significant updates or maintenance activity since then. It differentiates itself by offering a concise, chainable syntax for deeply nested query structures, making it easier to read and write complex queries compared to manual JSON object manipulation.

npm install esq
INSTALL
IMPORT
SIG · ESQ
E
esq
databasejavascriptv1.0.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

ESQ
const ESQ = require('esq'); const esq = new ESQ();
import ESQ from 'esq'; // ESQ is CJS-only import { ESQ } from 'esq'; // ESQ is CJS-only
ESQ is a CommonJS-only library. ESM imports are not supported and will result in errors.
ESQ (Browser Global)
// In browser, after <script src="esq.js"></script> const esq = new ESQ();
When included via a script tag in a browser, ESQ exposes itself as a global constructor function.
esq.query
esq.query('bool', ['must'], { match: { user: 'kimchy' } });
The `query` method is the primary API for building nested query structures, accepting strings for path segments and an array to create array nodes.

Demonstrates how to initialize ESQ and incrementally build a complex boolean Elasticsearch query object.

const ESQ = require('esq'); const esq = new ESQ(); // Build a boolean query with a 'must' clause esq.query('bool', ['must'], { match: { user: 'kimchy' } }); // Add a minimum_should_match to the same boolean query esq.query('bool', 'minimum_should_match', 1); // Add another 'should' clause to the existing boolean query esq.query('bool', ['should'], { term: { status: 'active' } }); // Get the final query object const query = esq.getQuery(); console.log(JSON.stringify(query, null, 2)); /* Expected output: { "bool": { "must": [ { "match": { "user": "kimchy" } } ], "minimum_should_match": 1, "should": [ { "term": { "status": "active" } } ] } } */
Debug
Known issues
gotchaThe ESQ project appears to be abandoned. The last update was in April 2016, and there has been no significant maintenance, new features, or bug fixes since then. Use with caution for new projects.
fix
Consider using more actively maintained Elasticsearch query builders or manually constructing query DSL for modern applications.
affects: >=1.0.0
breakingESQ is a CommonJS-only library and does not officially support ES Modules (ESM). Attempting to import it using `import` statements in an ESM context will result in errors.
fix
Ensure your project uses CommonJS (`require()`) when importing ESQ, or use a bundler that transpiles CommonJS to ESM if absolutely necessary (e.g., for browser builds).
affects: >=1.0.0
gotchaThe library does not ship with TypeScript declaration files (.d.ts). Integrating ESQ into a TypeScript project will require creating manual type declarations or using `@ts-ignore`.
fix
Create a `declarations.d.ts` file with `declare module 'esq';` or more specific types if needed. Alternatively, disable type checking for ESQ imports.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: ESQ is not a constructor
Attempting to instantiate ESQ after an incorrect ESM import (e.g., `import ESQ from 'esq';`) where `ESQ` might resolve to `undefined` or the module object itself, or when a bundler fails to correctly expose the default export.
fix
Ensure you are importing ESQ using CommonJS syntax: `const ESQ = require('esq');`. If in a browser, ensure the `esq.js` script is loaded before `new ESQ()` is called.
ReferenceError: require is not defined
This error occurs when trying to use `require('esq')` in an environment that only supports ES Modules natively (e.g., Node.js with `"type": "module"` or modern browsers without a CJS transpiler).
fix
Run your application in a Node.js environment configured for CommonJS, or use a build tool (like Webpack or Rollup) that can transpile CommonJS modules for ESM or browser environments.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Resources
esq — npm install esq · libregistry