Elasticsearch错误“客户注意到服务器不是Elasticsearch,我们不支持此未知产品”。

发布于 2025-01-31 19:50:10 字数 1369 浏览 1 评论 0原文

我使用OpenSearch Docker Image在本地服务器中设置了一个弹性搜索实例。

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

我可以看到该实例正在启动并运行https:// localhost:9200/

试图执行简单的搜索时,我会遇到以下错误。

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

我还尝试了最新的弹性搜索客户端,但它给了我连接错误。

   error ConnectionError: unable to verify the first certificate

代码样本:

//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)
    })

非常感谢您的帮助。

谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

热血少△年 2025-02-07 19:50:10

您有一个Elasticsearch客户端版本,该版本更近于7.10.2,即OpenSearch的分支版本。

您应该降级客户库匹配7.10.2,或使用 opensearch javascript javascript客户端。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文