🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

elastic-builder

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
e

elastic-builder

A JavaScript implementation of the elasticsearch Query DSL

2.31.0
latest
99

Supply Chain Security

100

Vulnerability

100

Quality

78

Maintenance

100

License

Version published
Weekly downloads
219K
0.69%
Maintainers
0
Weekly downloads
 
Created
Issues
21

What is elastic-builder?

The elastic-builder npm package is a library for building Elasticsearch queries and aggregations using a fluent API. It simplifies the process of constructing complex Elasticsearch queries by providing a set of builder classes that can be chained together.

What are elastic-builder's main functionalities?

Building Queries

This feature allows you to build various types of queries such as match, term, range, etc. The code sample demonstrates how to build a simple match query.

const bodyBuilder = require('elastic-builder');

const query = bodyBuilder()
  .query('match', 'message', 'this is a test')
  .build();

console.log(JSON.stringify(query, null, 2));

Aggregations

This feature allows you to build aggregations like terms, histogram, date_histogram, etc. The code sample demonstrates how to build a terms aggregation.

const bodyBuilder = require('elastic-builder');

const aggregation = bodyBuilder()
  .aggregation('terms', 'user', { size: 10 })
  .build();

console.log(JSON.stringify(aggregation, null, 2));

Combining Queries and Aggregations

This feature allows you to combine queries and aggregations in a single request. The code sample demonstrates how to build a query with an aggregation.

const bodyBuilder = require('elastic-builder');

const combined = bodyBuilder()
  .query('match', 'message', 'this is a test')
  .aggregation('terms', 'user', { size: 10 })
  .build();

console.log(JSON.stringify(combined, null, 2));

Other packages similar to elastic-builder

FAQs

Package last updated on 05 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts