OpenSearch clients in Python, Go, and Node.js

Thu, Sep 30, 2021 · Kyle Davis

Last month, the project announced the intention to release OpenSearch specific clients and today the first batch are ready for production use. You can get opensearch-py from PyPI, install opensearch-js from npm and start using opensearch-go.

Let’s take a brief look at how to get going on these client libraries. You can find more info on the README file for each repo.

Python

To install opensearch-py, you can use pip:

$ pip install opensearch-py

From there you can import it into your code:

from opensearchpy import OpenSearch

Node.js

Installing the JavaScript client in Node.js is through npm:

$ npm i @opensearch-project/opensearch

You can use it in your script by requiring the module:

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

Golang

You can install opensearch-go as a dependency with go get:

$ go get github.com/opensearch-project/opensearch-go@1.0

The golang implementation is separated into distinct packages (opensearchapi for the OpenSearch API, opensearchtransport for transport and connection, and opensearchutil for helper functions):

import (
    ...
    opensearch "github.com/opensearch-project/opensearch-go"
    opensearchapi "github.com/opensearch-project/opensearch-go/opensearchapi"
    opensearchtransport "github.com/opensearch-project/opensearch-go/opensearchtransport"
    opensearchutil "github.com/opensearch-project/opensearch-go/opensearchutil"
    ...
)

How do these clients fit in?

opensearch-py, opensearch-js, and opensearch-go are derived from elasticsearch-py, elasticsearch-js, and go-elasticsearch respectively and will work with OpenSearch and open source Elasticsearch. Each of these clients follows syntax of the previous projects closely and moving your custom code over should be a matter of changing over the naming.

What’s next?

The project team is moving forward in the public for the Java client and will soon make public repos available for .NET, Ruby, Rust, Perl, and PHP clients as well as the Hadoop and HDFS connectors. Additionally, the Python DSL query builder library has been identified as a target for OpenSearch.

How can you help?

OpenSearch is a community-driven project and your input is always valued and appreciated - feel free to add an issue or pull request on GitHub orpost in the forum category on clients. If these clients are important to you or your work, consider taking on a maintainer role where you can have a real impact on the ongoing direction and implementations. Together, let’s build a great set of clients!

Acknowledgements

The following people contributed to opensearch-py, opensearch-js, or opensearch-go: rushiagr, axeoman, vchrombie, deztructor, VijayanB, peternied, peterzhuamazon, ananzh, boktorbb-amzn, hansott, and henvic.