在AWS OpenSearch客户端配置中,需要关闭"verifyHostnames"选项。以下为示例代码:
const OpenSearch = require('opensearch-node');
const opensearchClient = new OpenSearch({
host: 'your-opensearch-endpoint-url',
amazonES: {
region: 'your-region',
accessKey: 'your-access-key',
secretKey: 'your-secret-key'
},
modifyEndpoint: (endpoint) => {
// Disable hostname verification
endpoint.host = endpoint.host.replace('.es.amazonaws.com', '');
endpoint.protocol = 'https:';
endpoint.rejectUnauthorized = false;
return endpoint
}
});
在配置示例代码中,将"verifyHostnames"选项关闭,即设置"rejectUnauthorized"为false。这允许AWS OpenSearch客户端连接到Elasticsearch服务器,而不需要验证主机名。