Socket
Socket
Sign inDemoInstall

@opensearch-project/opensearch

Package Overview
Dependencies
Maintainers
8
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opensearch-project/opensearch - npm Package Compare versions

Comparing version 2.4.0 to 2.5.0

api/api/http.js

11

api/index.js

@@ -57,2 +57,3 @@ /*

const getSourceApi = require('./api/get_source');
const HttpApi = require('./api/http');
const indexApi = require('./api/index');

@@ -93,2 +94,3 @@ const IndicesApi = require('./api/indices');

const kFeatures = Symbol('Features');
const kHttp = Symbol('Http');
const kIndices = Symbol('Indices');

@@ -108,2 +110,3 @@ const kIngest = Symbol('Ingest');

this[kFeatures] = null;
this[kHttp] = null;
this[kIndices] = null;

@@ -270,2 +273,10 @@ this[kIngest] = null;

},
http: {
get() {
if (this[kHttp] === null) {
this[kHttp] = new HttpApi(this.transport, this[kConfigurationError]);
}
return this[kHttp];
},
},
indices: {

@@ -272,0 +283,0 @@ get() {

@@ -753,2 +753,9 @@ /*

export interface HttpParams extends Generic {
path: string;
querystring?: Record<string, any>;
headers?: Record<string, any>;
body?: Record<string, any> | string | Array<string | Record<string, any>>;
}
export interface Index<T = RequestBody> extends Generic {

@@ -755,0 +762,0 @@ id?: string;

36

CHANGELOG.md

@@ -14,2 +14,36 @@ # CHANGELOG

## [2.5.0]
### Added
- Added deprecation warnings for Index Template APIs ([654](https://github.com/opensearch-project/opensearch-js/pull/645))
- Added `http` functions: `connect`, `delete`, `get`, `head`, `options`, `patch`, `post`, `put`, and `trace` ([#649](https://github.com/opensearch-project/opensearch-js/pull/649))
- Added `samples/search.js` and updated `guides/search.md` to provide example to search functionality ([#656](https://github.com/opensearch-project/opensearch-js/pull/656))
- Added `samples/msearch.js` and `guides/msearch.md` to provide example to multi-search functionality ([#657](https://github.com/opensearch-project/opensearch-js/pull/657))
- Updated `guides/index_lifecycle.md` to provide example of `ignore_unavailable: true` while deleting indices. ([665](https://github.com/opensearch-project/opensearch-js/pull/665))
- Add expiration buffer to prevent credentials to expire earlier than request may finish in case AWS SDK v3 is used. ([678](https://github.com/opensearch-project/opensearch-js/pull/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
### Changed
### Deprecated
### Removed
- Removed fixture lines that git-secrets wrongly flagged as passwords/secrets ([654](https://github.com/opensearch-project/opensearch-js/pull/645))
### Fixed
- Add new types to `package.json` exports configuration for ESM support ([#674](https://github.com/opensearch-project/opensearch-js/pull/674))
### Security
## [2.4.0]

@@ -190,2 +224,2 @@ ### Added

- Fix mutability of connection headers ([#291](https://github.com/opensearch-project/opensearch-js/issues/291))
- Fix mutability of connection headers ([#291](https://github.com/opensearch-project/opensearch-js/issues/291))

4

guides/index_lifecycle.md

@@ -142,5 +142,5 @@ # Index Lifecycle

```javascript
client.indices.delete({index: ['movies', 'paintings', 'burner'], ignore: 404})
client.indices.delete({index: ['movies', 'paintings', 'burner'], ignore_unavailable: true,})
```
Notice that we are passing `ignore: 404` to the request. This tells the client to ignore the `404` error if the index doesn't exist for deletion. Without it, the above `delete` request will throw an error because the `movies` index has already been deleted in the previous example.
Notice that we are passing `ignore_unavailable: true` to the request. This tells the client to ignore throwing error and deleting the index if it doesn't exist. Without it, the above `delete` request will throw an error because the `movies` index has already been deleted in the previous example.

@@ -147,0 +147,0 @@ ## Cleanup

# Search
OpenSearch provides a powerful search API that allows you to search for documents in an index. The search API supports a number of parameters that allow you to customize the search operation. In this guide, we will explore the search API and its parameters.
OpenSearch provides a powerful search API that allows you to search for documents in an index. The search API supports a number of parameters that allow you to customize the search operation. In this guide, we will explore the search API and its parameters. To complement your exploration of the OpenSearch Search API and its parameters, a working sample is available in [`../samples/search.js`](../samples/search.js).
# Setup

@@ -4,0 +4,0 @@ Let's start by creating an index and adding some documents to it:

@@ -17,2 +17,3 @@ /*

const crypto = require('crypto');
const { toMs } = Transport.internals;

@@ -106,2 +107,8 @@ const getAwsSDKCredentialsProvider = async () => {

const currentCredentials = credentialsState.credentials;
/**
* For AWS SDK V3
* Make sure token will expire no earlier than `expiryBufferMs` milliseconds in the future.
*/
const expiryBufferMs = toMs(options.requestTimeout || this.requestTimeout);
let expired = false;

@@ -125,3 +132,6 @@ if (!currentCredentials) {

// AWS SDK V3, Credentials.expiration is a Date object
else if (currentCredentials.expiration && currentCredentials.expiration < new Date()) {
else if (
currentCredentials.expiration &&
currentCredentials.expiration.getTime() - Date.now() < expiryBufferMs
) {
expired = true;

@@ -128,0 +138,0 @@ }

@@ -200,4 +200,4 @@ /*

: typeof options.maxRetries === 'number'
? options.maxRetries
: this.maxRetries;
? options.maxRetries
: this.maxRetries;
const compression = options.compression !== undefined ? options.compression : this.compression;

@@ -733,2 +733,3 @@ let request = { abort: noop };

lowerCaseHeaders,
toMs,
};

@@ -11,3 +11,2 @@ ## Overview

| Kawika (Rocky) Avilla | [kavilla](https://github.com/kavilla) | Amazon |
| Sean Neumann | [seanneumann](https://github.com/seanneumann) | Amazon |
| Daniel Doubrovkine | [dblock](https://github.com/dblock) | Amazon |

@@ -21,5 +20,6 @@ | Vacha Shah | [VachaShah](https://github.com/VachaShah) | Amazon |

| Maintainer | GitHub ID | Affiliation |
|---------------|-------------------------------------------|-------------|
| Bishoy Boktor | [boktorbb](https://github.com/boktorbb) | Amazon |
| Mihir Soni | [mihirsoni](https://github.com/mihirsoni) | Amazon |
| Maintainer | GitHub ID | Affiliation |
|---------------|-----------------------------------------------|-------------|
| Bishoy Boktor | [boktorbb](https://github.com/boktorbb) | Amazon |
| Mihir Soni | [mihirsoni](https://github.com/mihirsoni) | Amazon |
| Sean Neumann | [seanneumann](https://github.com/seanneumann) | Amazon |

@@ -12,2 +12,8 @@ {

},
"./api/new": {
"types": "./api/new.d.ts"
},
"./api/types": {
"types": "./api/types.d.ts"
},
"./aws": "./lib/aws/index.js",

@@ -27,3 +33,3 @@ "./*": "./*"

"homepage": "https://www.opensearch.org/",
"version": "2.4.0",
"version": "2.5.0",
"versionCanary": "7.10.0-canary.6",

@@ -80,3 +86,3 @@ "keywords": [

"node-fetch": "^3.2.10",
"ora": "^7.0.1",
"ora": "^8.0.1",
"prettier": "^3.0.1",

@@ -83,0 +89,0 @@ "pretty-hrtime": "^1.0.3",

@@ -8,8 +8,13 @@ # User Guide

- [Using AWS V3 SDK](#using-aws-v3-sdk)
- [Enable Handling of Long Numerals](#enable-handling-of-long-numerals)
- [Enable Handling of Long Numerals](#enable-handling-of-long-numerals)
- [Create an Index](#create-an-index)
- [Add a Document to the Index](#add-a-document-to-the-index)
- [Search for the Document](#search-for-the-document)
- [Multi-Search (msearch)](#multi-search-msearch)
- [Delete the document](#delete-the-document)
- [Delete the index](#delete-the-index)
- [Create a Point in Time](#create-a-point-in-time)
- [Get all PITs](#get-all-pits)
- [Delete a Point in Time](#delete-a-point-in-time)
- [Delete all PITs](#delete-all-pits)
- [Empty all Pool Connections](#empty-all-pool-connections)

@@ -98,4 +103,4 @@

// when the credentials are expired.
// The Client will refresh the Credentials only when they are expired.
// With AWS SDK V2, Credentials.refreshPromise is used when available to refresh the credentials.
// The Client will treat the Credentials as expired if within
// `requestTimeout` ms of expiration (default is 30000 ms).

@@ -109,2 +114,3 @@ // Example with AWS SDK V3:

}),
requestTimeout: 60000, // Also used for refreshing credentials in advance
node: 'https://search-xxx.region.es.amazonaws.com', // OpenSearch domain URL

@@ -200,2 +206,26 @@ // node: "https://xxx.region.aoss.amazonaws.com" for OpenSearch Serverless

## Multi-Search (msearch)
```javascript
const queries = [
{},
{ query: { match: { author: 'Stephen King' } } },
{},
{ query: { match: { title: 'The Outsider' } } },
];
const multiSearchResponse = await client.msearch({
index: index_name,
body: queries,
});
multiSearchResponse.body.responses.map((res) =>
res.hits.hits.map((movie) => {
console.log(movie._source);
})
);
```
Explore `msearch` further with a detailed guide in [msearch.md](guides/msearch.md) and find sample code in [msearch.js](samples/msearch.js).
## Delete the document

@@ -202,0 +232,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc