0

I set up an elastic search instance in my local server using the OpenSearch docker image.

$ docker run -p 9200:9200 -p 9600:9600 -e "discovery.type=single-node" opensearchproject/opensearch:1.3.1

I can see the instance is up and running https://localhost:9200/

When trying to execute a simple search I am getting the following error.

ProductNotSupportedError: The client noticed that the server is not Elasticsearch and we do not support this unknown product.

I also tried the latest elastic search client but it's giving me a connection error.

   error ConnectionError: unable to verify the first certificate

Code sample:

//const { Client } = require('@elastic/elasticsearch') // Got connection error when using latest version 
const {Client: Client} = require('es7')
var connectionString = 'https://admin:admin@localhost:9200'
const client = new Client({
    node: connectionString,
    ssl: {
        rejectUnauthorized: false
    }
})
client.info()
    .then(async response => {
        console.log('success', response.statusCode);
        const result = await client.search({
            index: 'r7',
            query: {
                match: {
                    subtype: 'a'
                }
            }
        })
        console.log('result', result)
        console.log('count', result.hits.hits)
    })
    .catch(error => {
        console.error('error', error)
    })

Your help is much appreciated.

Thank you.

1 Answer 1

2

You have an Elasticsearch client version that is more recent than 7.10.2, the version at which Opensearch was forked.

You should either downgrade the client library to match 7.10.2, or use the Opensearch Javascript client instead.

1
  • I downgraded it to 7.6.1, now the search is working. But I am not sure which documentation to follow for writing queries. I am not sure about using an old version of the client ie 7.6.1 in my production environment. Can you guide me, your comments are much appreciated.
    – Dibish
    Commented May 25, 2022 at 7:40

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.