如果它不存在,我正在嘗試使用 OnModuleInit (NestJs) 創建一個彈性搜索索引。它在我的本地機器上運行良好,但是當我嘗試部署到 AWS ES 集群時,這部分給出了這樣的錯誤。
ElasticsearchModule.registerAsync({
useFactory: async () => ({
node: process.env.ES_ENDPOINT,
maxRetries: 3,
requestTimeout: 60000,
pingTimeout: 60000,
}),
})
export class ClientElasticSearchModule implements OnModuleInit {
constructor(private clientSearchService: ClientElasticSearchService) {}
async onModuleInit() {
await this.clientSearchService.createIndex();
}
}
這是我創建索引的地方:
await this.elasticsearchService.indices.create({
index: clientsIndex,
body: {
settings: {
analysis: {...},
},
mappings: {
properties: {
name: {
type: 'text',
fields: {
complete: {
type: 'text',
analyzer: 'autocomplete_analyzer',
search_analyzer: 'autocomplete_search_analyzer',
},
},
},
},
},
},
});
錯誤資訊:
ResponseError: Response Error
at onBody (/code/node_modules/@elastic/elasticsearch/lib/Transport.js:337:23)
at IncomingMessage.onEnd (/code/node_modules/@elastic/elasticsearch/lib/Transport.js:264:11)
at IncomingMessage.emit (node:events:402:35)
at IncomingMessage.emit (node:domain:475:12)
at endReadableNT (node:internal/streams/readable:1343:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
meta: {
body: '',
statusCode: 403,
headers: {
date: 'Fri, 14 Jan 2022 16:18:46 GMT',
'content-type': 'application/json',
'content-length': '73',
connection: 'keep-alive',
'x-amzn-requestid': '8b3cded2-f210-4c79-ab48-ff517725a1e2',
'access-control-allow-origin': '*'
},
meta: {
context: null,
request: [Object],
name: 'elasticsearch-js',
connection: [Object],
attempts: 0,
aborted: false
}
}
}
uj5u.com熱心網友回復:
這看起來像您的 AWS Opensearch(Elasticsearch 引擎蓋下的相同技術)實體正在回傳 403。這可能意味著您需要為您的實體設定 IAM 角色和正確的訪問權限。請參閱AWS 檔案
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/414392.html
標籤:
上一篇:如何在ElasticsearchJavaAPI客戶端中禁用兼容性標頭?
下一篇:分布式系統如何保證讀取一致性?
