AWS OpenSearch client error: unable to verify that the server is Elasticsearch

Viewed 2200

I am trying to write a lambda to get data from OpenSearach domain.

const { Client } = require('@opensearch-project/opensearch');
const { createAWSConnection, awsGetCredentials } = require('@acuris/aws-es-connection');

const test = async () => {

    const awsCredentials = await awsGetCredentials();
    const AWSConnection = createAWSConnection(awsCredentials);
    const client = new Client({
        ...AWSConnection,
        node: 'https://<domain-name>.us-east-2.es.amazonaws.com'
    });

    // inside async func
    await client.cat.help();
};
test();

Error:

(node:32926) ProductNotSupportedSecurityError: The client is unable to verify that the server is Elasticsearch due to security privileges on the server-side. Some functionality may not be compatible if the server is running an unsupported product.
2 Answers

I faced with the same error but I used @elasticsearch lib instead of @opensearch-project. Maybe you can try it too. Error was resolved by downgrading @elasticsearch lib version.

Try using the Elasticsearch client version 7.13.0. According to the docs, it is the latest Elasticsearch client that is compatible with OpenSearch.

Related