Package detail

@opensearch-project/opensearch

opensearch-project2.9mApache-2.03.5.1

The official OpenSearch client for Node.js

opensearch, opensearchDashboards, mapping, REST

readme

Nodejs Integration Bundler codecov Chat PRs welcome!

OpenSearch logo

OpenSearch Node.js client

Welcome!

opensearch-js is a community-driven, open source fork of elasticsearch-js licensed under the Apache v2.0 License. For more information, see opensearch.org.

Example use

The OpenSearch JavaScript client provides a safer and easier way to interact with your OpenSearch cluster. Rather than using OpenSearch from the browser and potentially exposing your data to the public, you can build an OpenSearch client that takes care of sending requests to your cluster.

The client contains a library of APIs that let you perform different operations on your cluster and return a standard response body. The example here demonstrates some basic operations like creating an index, adding documents, and searching your data.

Setup

To add the client to your project, install it with npm:

npm i @opensearch-project/opensearch

If you prefer to add the client manually or just want to examine the source code, see opensearch-js on GitHub.

Then require the client:

const { Client } = require('@opensearch-project/opensearch');

Sample code

Please see the USER_GUIDE for code snippets.

Project Resources

Code of Conduct

This project has adopted the Amazon Open Source Code of Conduct. For more information see the Code of Conduct FAQ, or contact opensource-codeofconduct@amazon.com with any additional questions or comments.

License

This project is licensed under the Apache v2.0 License.

Copyright

Copyright OpenSearch Contributors. See NOTICE for details.

changelog

CHANGELOG

Inspired by Keep a Changelog

[Unreleased]

Added

Dependencies

Changed

Deprecated

Removed

Fixed

Security

[3.5.1]

Fixed

  • Api Generator: fix HEAD request boolean response type (#1006)

[3.5.0]

Added

Dependencies

Changed

  • Updated API to match the OpenSearch spec from April 02, 2025

    Deprecated

    Removed

    Fixed

  • Api Generator: API functions that perform HEAD requests now return boolean values instead of the response body (#993)
  • Api Generator: Account for oneOf nested within AllOf (#993)
  • Api Generator: Removed duplicated component types within intersection/union types (#998)

    Security

[3.4.0]

Changed

  • Updated API to match the OpenSearch spec from Feb 24, 2025

[3.3.0]

Changed

  • Updated API to match the OpenSearch spec from Feb 11, 2025

    Fixed

  • Skip nodes that are not ready yet (#984)

[3.2.0]

Changed

  • Updated API to match the OpenSearch spec from Jan 21, 2025

[3.1.0]

Added

  • Added export of component types (#955)

    Changed

  • Updated API to match the OpenSearch spec from Jan 09, 2025

[3.0.0]

Added

  • Added API Generator (#789)
  • Added missing API functions and modules.
  • Added missing request and response types.

    Changed

  • All API functions are now generated from the OpenSearch API specification.
  • API request and response types are now generated from the OpenSearch API specification.
  • Overhauled API codebase and break it into smaller, more manageable files for better readability and maintainability.

    Deprecated

  • Support for snake_cased API function aliases have been deprecated to conform to JavaScript naming conventions.

    Removed

  • Removed support for API param aliases. That is, the API functions now only accept params with the exact names specified in the OpenSearch API specification.
  • Removed support for overriding HTTP methods in API functions.
  • Removed support for Node.js 10 and 12. The minimum supported Node.js version is now 14.

[2.13.0]

Dependencies

  • Bumps @babel/traverse from 7.22.8 to 7.24.7
  • Bumps @types/node from 22.5.0 to 22.5.4
  • Bumps aws4 from 1.13.0 to 1.13.2
  • Bumps aws4 from 1.13.1 to 1.13.2
  • Bumps debug from 4.3.6 to 4.3.7
  • Bumps eslint-plugin-prettier from 5.1.3 to 5.2.1
  • Bumps micromatch from 4.0.7 to 4.0.8
  • Bumps simple-git from 3.24.0 to 3.26.0
  • Bumps simple-git from 3.25.0 to 3.26.0
  • Bumps simple-statistics from 7.8.4 to 7.8.5

    Fixed

  • Upgrade JSON11 from 1.1.2 to 2.0.0 to ensure UTF-8 safety when stringifying JSON data
  • Fixed typo cause JSON11 parse will always be executed when json string has number inside

[2.12.0]

Dependencies

  • Bumps @babel/eslint-parser from 7.24.8 to 7.25.1
  • Bumps @types/node from 20.14.11 to 22.5.0
  • Bumps aws4 from 1.13.0 to 1.13.1
  • Bumps ora from 8.0.1 to 8.1.0
  • Bumps simple-statistics from 7.8.3 to 7.8.4

    Fixed

  • Fixed docker-compose command in Makefile (#845)

[2.11.0]

Changed

  • Return a transport object from AwsSigv4SignerTransport.request that has an .abort() method that allows in-flight requests to be canceled

    Dependencies

  • Bumps @aws-sdk/types from 3.577.0 to 3.609.0
  • Bumps @babel/eslint-parser from 7.24.7 to 7.24.8
  • Bumps @types/node from20.14.2 to 20.14.11
  • Bumps eslint-plugin-prettier from 5.1.3 to 5.2.1
  • Bumps faker from 5.5.3 to 6.6.6
  • Bumps prettier from 3.3.1 to 3.3.3
  • Bumps rimraf from 5.0.7 to 6.0.1
  • Bumps semver from 7.6.2 to 7.6.3
  • Bumps simple-git from 3.24.0 to 3.25.0
  • Bumps ws from 7.5.9 to 7.5.10

    Fixed

  • Add missing types in package.json for aws-v3 (810)

[2.10.0]

Added

  • Added Rollups API (744)
  • Added Transforms API (744)

    Dependencies

  • Bumps @types/node from 20.14.0 to 20.14.2
  • Bumps @babel/eslint-parser from 7.24.6 to 7.24.7
  • Bumps prettier from 3.3.0 to 3.3.1

[2.9.1]

Dependencies

  • Bumps json11 from 1.0.4 to 1.1.2
  • Bumps graceful-fs from 4.2.8 to 4.2.10
  • Bumps picomatch from 2.3.0 to 2.3.1

    Security

  • [CVE-2024-4068] Bumps braces from 3.0.2 to 3.0.3
  • [CVE-2024-4067] Bumps micromatch from 4.0.4 to 4.0.7

[2.9.0]

Dependencies

  • Bumps @aws-sdk/types from 3.535.0 to 3.577.0
  • Bumps @babel/eslint-parser from 7.24.1 to 7.24.6
  • Bumps @types/node from 20.12.9 to 20.14.0
  • Bumps semver from 7.6.0 to 7.6.2
  • Bumps rimraf from 5.0.5 to 5.0.7
  • Bumps aws4 from 1.12.0 to 1.13.0
  • Bumps prettier from 3.2.5 to 3.3.0
  • Bumps debug from 4.3.4 to 4.3.5

    Changed

  • Upgraded the parsing and serialization of long numerals to employ JSON11 (784).

    Fixed

  • Missing type definitions for @opensearch-project/opensearch/aws-v3 (776).

[2.8.0]

Added

  • Added @opensearch-project/opensearch/aws-v3 import (758).

    Dependencies

  • Bumps @types/node from 20.12.5 to 20.12.9
  • Bumps semver from 5.7.1 to 7.6.0
  • Bumps dedent from 1.5.1 to 1.5.3
  • Bumps jsdoc from 4.0.2 to 4.0.3

    Changed

  • Disabled fail_ci_if_error for upload coverage step in coverage workflow (#755

[2.7.0]

Dependencies

  • Bumps @aws-sdk/types from 3.523.0 to 3.535.0
  • Bumps simple-git from 3.22.0 to 3.24.0
  • Bumps @types/node from 20.11.25 to 20.12.5
  • Bumps @babel/eslint-parser from 7.23.10 to 7.24.1

    Changed

  • Added search_pipeline (#716)

[2.6.0]

Added

  • Inherit AwsSigV4 in .child (#725)

    Dependencies

  • Bumps prettier from 3.1.1 to 3.2.5
  • Bumps @aws-sdk/types from 3.485.0 to 3.523.0
  • Bumps @types/node from 20.10.7 to 20.11.25
  • Bumps eslint-plugin-prettier from 5.1.2 to 5.1.3
  • Bumps @babel/eslint-parser from 7.23.3 to 7.23.10
  • Bumps semver from 7.5.1 to 7.6.0
  • Bumps cross-zip from 4.0.0 to 4.0.1
  • Bumps eslint from 8.56.0 to 8.57.0

    Changed

  • Updated integration tests to use strong password in OS 2.12 and up (#707)
  • Simplified client creation in the guides (#707)
  • Corrected guides/bulk.md (#616)

    Removed

  • Removed AutoHeal(#707)

    Fixed

  • Make optional fields optional in MappingGenericProperty (708)

[2.5.0]

Added

  • Added deprecation warnings for Index Template APIs (654)
  • Added http functions: connect, delete, get, head, options, patch, post, put, and trace (#649)
  • Added samples/search.js and updated guides/search.md to provide example to search functionality (#656)
  • Added samples/msearch.js and guides/msearch.md to provide example to multi-search functionality (#657)
  • Updated guides/index_lifecycle.md to provide example of ignore_unavailable: true while deleting indices. (665)
  • Add expiration buffer to prevent credentials to expire earlier than request may finish in case AWS SDK v3 is used. (678)

    Dependencies

  • Bumps @aws-sdk/types from 3.418.0 to 3.451.0
  • Bumps @types/node from 20.6.5 to 20.9.0
  • Bumps eslint from 8.50.0 to 8.54.0
  • Bumps @babel/traverse from 7.15.0 to 7.23.2
  • Bumps eslint-plugin-prettier from 5.0.0 to 5.0.1
  • Bumps react-devtools-core from 4.25.0 to 4.28.4
  • Bumps simple-git from 3.20.0 to 3.21.0
  • Bumps prettier from 3.0.3 to 3.1.0
  • Bumps @babel/eslint-parser from 7.22.15 to 7.23.3
  • Bumps @types/node from 20.9.0 to 20.10.7
  • Bumps eslint from 8.54.0 to 8.56.0
  • Bumps @aws-sdk/types from 3.451.0 to 3.485.0
  • Bumps prettier from 3.1.0 to 3.1.1
  • Bumps eslint-plugin-prettier from 5.0.1 to 5.1.2
  • Bumps eslint-config-prettier from 9.0.0 to 9.1.0
  • Bumps ora from 7.0.1 to 8.0.1
  • Bumps simple-git from 3.21.0 to 3.22.0

    Removed

  • Removed fixture lines that git-secrets wrongly flagged as passwords/secrets (654)

    Fixed

  • Add new types to package.json exports configuration for ESM support (#674)

    Security

[2.4.0]

Added

  • Added Security API (#606)
  • Documentation for edge-case in Sigv4Signer (#622)

    Dependencies

  • Bumps rimraf from 5.0.0 to 5.0.5
  • Bumps eslint from 8.41.0 to 8.50.0
  • Bumps dedent from 0.7.0 to 1.5.1
  • Bumps @types/node from 20.2.5 to 20.6.5
  • Bumps @aws-sdk/types from 3.341.0 to 3.418.0
  • Bumps @babel/eslint-parser from 7.21.8 to 7.22.15
  • Bumps prettier from 2.8.8 to 3.0.3
  • Bumps eslint-plugin-prettier from 4.0.0 to 5.0.0
  • Bumps node-fetch from 3.3.1 to 3.3.2
  • Bumps tap from 16.3.4 to 16.3.8
  • Bumps eslint-config-prettier from 8.8.0 to 9.0.0
  • Bumps ora from 6.3.1 to 7.0.1
  • Bumps simple-git from 3.18.0 to 3.20.0

    Changed

  • Make handling of long numerals an option that is disabled by default (#557)
  • Add enableLongNumeralSupport to the type definition for ClientOptions (#598)

    Fixed

  • Fix wrong documentation for file serach.md regarding search_after param (#584)

[2.3.0]

Added

  • Add serialization and deserialization of numerals larger than Number.MAX_SAFE_INTEGER (#544)

    Dependencies

  • Bumps prettier from 2.8.7 to 2.8.8
  • Bumps ora from 6.1.2 to 6.3.1
  • Bumps @types/node from 18.15.11 to 20.2.5
  • Bumps eslint from 8.38.0 to 8.41.0
  • Bumps xmlbuilder2 from 3.0.2 to 3.1.1
  • Bumps simple-git from 3.17.0 to 3.18.0
  • Bumps @babel/eslint-parser from 7.21.3 to 7.21.8
  • Bumps @aws-sdk/types from 3.257.0 to 3.341.0
  • Bumps semver from 7.3.8 to 7.5.1
  • Bumps node-fetch from 3.2.10 to 3.3.1

    Changed

  • Implemented Docker Image caching for integration-unreleased workflow (#387)
  • Add upgrading NPM to all workflows running older Node.js versions (#545)
  • Upgrade and secure the backport workflow (#547)

    Fixed

  • Fixed malformed bundler.yml (#497)

[2.2.1]

Added

  • Add release details to releasing.md (319)
  • Added Amazon OpenSearch Serverless in user_guide (#372)
  • Add guidelines on installing yarn, dependencies; instructions on running ESLint in developer_guide (#439)
  • Added pull_request_template (440)
  • Added guide for Search (#473)

    Dependencies

  • Bumps aws4 from 1.11.0 to 1.12.0
  • Bumps minimist from 1.2.6 to 1.2.8
  • Bumps tsd from 0.24.1 to 0.27.0
  • Bumps dezalgo from 1.0.3 to 1.0.4
  • Bumps simple-statistics from 7.7.0 to 7.8.3
  • Bumps eslint from 8.30.0 to 8.38.0
  • Downgrades @types/node from 18.11.19 to 17.0.45
  • Bumps ora from 5.4.1 to 6.1.2
  • Bumps @aws-sdk/types from 3.190.0 to 3.257.0
  • Bumps secure-json-parse from 2.4.0 to 2.7.0
  • Bumps simple-git from 3.15.1 to 3.17.0
  • Bumps deepmerge from 4.2.2 to 4.3.1
  • Bumps tap from 16.3.0 to 16.3.4
  • Bumps rimraf from 4.1.1 to 5.0.0
  • Bumps @types/node from 17.0.45 to 18.15.11
  • Bumps caniuse-lite from 1.0.30001249 to 1.0.30001469
  • Bumps eslint-config-prettier from 8.6.0 to 8.8.0
  • Bumps split2 from 4.1.0 to 4.2.0
  • Bumps prettier from 2.8.4 to 2.8.7
  • Bumps jsdoc from 4.0.0 to 4.0.2
  • Bumps @babel/eslint-parser from 7.19.1 to 7.21.3

    Changed

  • Remove test artifacts from gh_pages workflow (#335)
  • Make fields in BulkOperation optional to match OpenSearch Bulk API requirements (#378)
  • Remove guidance on using npm and switch completely to yarn in developer_guide (#439)
  • Change coverage, compatability, integration, integration with unreleased Open Search, node ci, bundler tests not to run on documentation change (441)
  • Change the Windows yarn installation troubleshoot steps (455)
  • Make callback arg in BaseConnectionPool, CloudConnectionPool and ConnectionPool optional (#451)

    Deprecated

  • Remove deprecation warnings in bulk.test.js (#434)

    Removed

  • Remove waitCluster in Integration Tests (#422)

    Fixed

  • Added missing types for AwsSigv4SignerOptions.service (#377)
  • Fixed deprecated folder mapping "./" in the "exports" field module resolution (#416)

  • [CVE-2022-25912] Bumps simple-git from 3.4.0 to 3.15.0 (#341)

[2.2.0]

Added

  • Add release details to releasing.md (319)
  • Allow overriding the aws service identifier in AwsSigv4Signer (333)
  • Added skip-changelog label (339)
  • Added jsdoc for documentation generation (#335)
  • Documented Transport#request (#335)
  • Documented all API methods (#335)
  • Added point in time APIs (#348)
  • Added support for Amazon OpenSearch Serverless (#356)
  • Added required array argument when invoking SerializationError (#419)
  • Removed unnecessary data argument when invoking OpenSearchClientError (#421)
  • Fixed typos in ConnectionPool (#427)
  • Added the solution for the possible error during yarn installation on Windows OS (#435)
  • Added missing createConnection method type definition in BaseConnectionPool )(#490)

    Dependencies

  • Bumps xmlbuilder2 from 2.4.1 to 3.0.2
  • Bumps minimatch from 3.0.4 to 3.1.2
  • Bumps eslint from 7.32.0 to 8.32.0
  • Replaced babel-eslint with @babel/eslint-parser
  • Bumps eslint-plugin-prettier from 4.0.0 to 4.2.1
  • Bumps json5 from 2.2.0 to 2.2.3
  • Bumps split2 from 3.2.2 to 4.1.0
  • Bumps @types/node from 15.14.7 to 18.11.19
  • Bumps prettier from 2.7.1 to 2.8.4
  • Bumps hpagent from 0.1.2 to 1.2.0
  • Bumps eslint-config-prettier from 8.5.0 to 8.6.0
  • Bumps rimraf from 3.0.2 to 4.1.1

    Changed

  • Remove test artifacts from gh_pages workflow (#335)
  • Make TimeoutError and RequestAbortedError classes' meta argument optional (#478)

    Security

  • [CVE-2022-25912] Bumps simple-git from 3.4.0 to 3.15.0 (#341)

[2.1.0]

Added

  • Github workflow for changelog verification (#306)
  • Add GitHub and Jenkins release workflow (#317)

    Dependencies

  • Bumps tsd from 0.22.0 to 0.24.1
  • Bumps semver from 7.3.7 to 7.3.8

    Fixed

  • Fix mutability of connection headers (#291)