Security News
vlt Debuts New JavaScript Package Manager and Serverless Registry at NodeConf EU
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
@opensearch-project/opensearch
Advanced tools
@opensearch-project/opensearch is an official client for OpenSearch, a community-driven, open-source search and analytics suite derived from Elasticsearch. This package allows developers to interact with OpenSearch clusters, perform CRUD operations, search, and manage indices, among other functionalities.
Connecting to an OpenSearch Cluster
This code demonstrates how to create a client instance to connect to an OpenSearch cluster running on localhost.
const { Client } = require('@opensearch-project/opensearch');
const client = new Client({ node: 'http://localhost:9200' });
Indexing Documents
This code sample shows how to index a document into an OpenSearch index named 'my-index'.
async function indexDocument() {
const response = await client.index({
index: 'my-index',
id: '1',
body: {
title: 'Test Document',
content: 'This is a test document.'
}
});
console.log(response);
}
indexDocument();
Searching Documents
This code demonstrates how to search for documents in an OpenSearch index using a match query.
async function searchDocuments() {
const response = await client.search({
index: 'my-index',
body: {
query: {
match: { title: 'Test' }
}
}
});
console.log(response.hits.hits);
}
searchDocuments();
Managing Indices
This code sample shows how to create a new index in OpenSearch.
async function createIndex() {
const response = await client.indices.create({
index: 'my-new-index'
});
console.log(response);
}
createIndex();
The 'elasticsearch' npm package is the official client for Elasticsearch, a distributed search and analytics engine. It provides similar functionalities to @opensearch-project/opensearch, such as connecting to clusters, indexing documents, searching, and managing indices. However, it is tailored specifically for Elasticsearch clusters.
The 'meilisearch' npm package is a client for MeiliSearch, an open-source, easy-to-use, and fast search engine. While it offers similar functionalities like indexing and searching documents, MeiliSearch focuses on simplicity and speed, making it a good alternative for smaller projects or those requiring quick setup.
The 'typesense' npm package is a client for Typesense, an open-source, typo-tolerant search engine optimized for instant search experiences. It provides functionalities for indexing and searching documents, similar to @opensearch-project/opensearch, but is designed to offer a more user-friendly and developer-friendly experience.
OpenSearch Node.js client
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.
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.
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');
Please see the USER_GUIDE for code snippets.
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.
This project is licensed under the Apache v2.0 License.
Copyright OpenSearch Contributors. See NOTICE for details.
[2.11.0]
AwsSigv4SignerTransport.request
that has an .abort()
method that allows in-flight requests to be canceled@aws-sdk/types
from 3.577.0 to 3.609.0@babel/eslint-parser
from 7.24.7 to 7.24.8@types/node
from20.14.2 to 20.14.11eslint-plugin-prettier
from 5.1.3 to 5.2.1faker
from 5.5.3 to 6.6.6prettier
from 3.3.1 to 3.3.3rimraf
from 5.0.7 to 6.0.1semver
from 7.6.2 to 7.6.3simple-git
from 3.24.0 to 3.25.0ws
from 7.5.9 to 7.5.10package.json
for aws-v3
(810)FAQs
The official OpenSearch client for Node.js
The npm package @opensearch-project/opensearch receives a total of 393,014 weekly downloads. As such, @opensearch-project/opensearch popularity was classified as popular.
We found that @opensearch-project/opensearch demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
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.
Security News
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
Security News
Research
The Socket Research Team uncovered a malicious Python package typosquatting the popular 'fabric' SSH library, silently exfiltrating AWS credentials from unsuspecting developers.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.