【问题标题】:how to exclude port number in host in elasticsearch.js client如何在 elasticsearch.js 客户端中排除主机中的端口号
【发布时间】:2018-05-24 19:37:51
【问题描述】:

我需要从 angular5 的 elastisearch.js 客户端调用没有端口号的弹性搜索 url

我需要像这样调用没有端口的 elasticsearch url

'https://myelasticsearch-api.xyz.com/api1/1.0'

但它总是像这样附加默认端口

'https://myelasticsearch-api.xyz.com:9200/api1/1.0'

private connect() {
    this.client = new Client({
    host: {
        host: 'myelasticsearch-api.xyz.com',
        port: '', 
        protocol:'https',
        headers: {
          'authorization': 'Bearer ' + this.accessTolken,
        },
        path:'/api1/1.0'
      },
      log: 'warning'
    });
}

【问题讨论】:

    标签: angular5 elasticsearch.js


    【解决方案1】:

    最终,我可以通过使用默认的 ssl 端口 443 来实现这一点

    private connect() {
     this.client = new Client({
     host: {
        host: 'myelasticsearch-api.xyz.com',
        port: 443, 
        protocol:'https',
        headers: {
          'authorization': 'Bearer ' + this.accessTolken,
        },
        path:'/api1/1.0'
      },
      log: 'warning'
     });
    }
    

    现在可以访问 url 'https://myelasticsearch-api.xyz.com/api1/1.0'

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-04
      • 1970-01-01
      • 2012-12-04
      • 1970-01-01
      • 2015-07-27
      • 1970-01-01
      • 2011-11-03
      • 1970-01-01
      相关资源
      最近更新 更多