我使用 OpenSearch docker 映像在本地服務器中設定了一個彈性搜索實體。
$ 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)
})
非常感謝您的幫助。
謝謝你。
uj5u.com熱心網友回復:
您有一個比 7.10.2 更新的 Elasticsearch 客戶端版本,即派生 Opensearch 的版本。
您應該將客戶端庫降級以匹配 7.10.2,或者改用Opensearch Javascript 客戶端。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/481750.html
上一篇:在Elasticsearch中,按查詢更新API是否會增加更新檔案的外部版本?
下一篇:無法部署Firestore云功能
