1

我正在尝试在我的 mongo db 数据库上创建搜索。我认为一个不错的选择是使用弹性搜索。所以我在aws elastic search上启动了一个集群。因为我有这个用于开发目的的弹性搜索,所以我已将访问策略设置为对域进行开放访问。

this.es_connection = new elasticsearch.Client("elastic search end point as given on aws es domain page");

this.es_connection.ping(
 {
   requestTimeout: 30000,
   hello: 'elasticsearch'
 }, 
 function(error) {
  if (error) {
    console.error('elasticsearch cluster is down!' + JSON.stringify(error));
  } else {
    logger.info('All is well in elasticsearch');
  }
 }
);  

检查我正在尝试在 npm 上 ping usgin elascticsearch 包。我没有获得实时连接。节点服务器在本地主机上运行。当我从自己的浏览器访问端点 url 时,我收到了成功消息。

如何将 aws es 服务与 mongoosastic 一起使用,我一直没有收到任何活动连接错误。如果 AWS/ES 是一个休息 api,我如何将它与 mongoosastic 一起使用。

4

1 回答 1

1

确保在连接期间指定您的 AWS 凭证。我建议使用这个库https://www.npmjs.com/package/http-aws-es。这对我有用:

var client = require('elasticsearch').Client({
  hosts: 'Your host',
  connectionClass: require('http-aws-es'),
  amazonES: {
    region: 'region',
    accessKey: 'key',
    secretKey: 'secretKey'
  }
});

然后还要确保进行正确的查询,否则会导致 400 错误。

于 2017-04-28T11:48:43.683 回答