Home > Software design >  Elasticsearch error "The client noticed that the server is not Elasticsearch and we do not supp
Elasticsearch error "The client noticed that the server is not Elasticsearch and we do not supp

Time:05-25

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.

CodePudding user response:

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.

  • Related