Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@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

The official OpenSearch client for Node.js

  • 2.9.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
474K
increased by0.28%
Maintainers
8
Weekly downloads
 
Created

What is @opensearch-project/opensearch?

@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.

What are @opensearch-project/opensearch's main 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();

Other packages similar to @opensearch-project/opensearch

Keywords

FAQs

Package last updated on 04 Jun 2024

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

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