无法创建一个有效的elasticsearch-py实例

时间:2017-08-14 15:30:59

标签: python django amazon-web-services elasticsearch

我已经运行了一个Amazon ElasticSearch Service,我可以使用curl / postman连接正常,但是当我尝试创建一个elasticsearch-py实例时,我的ide会无限期挂起。

endpoints = ['http://XXX.us-east-1.es.amazonaws.com',
             'http://XXX.us-east-1.es.amazonaws.com:443',
             'http://XXX.us-east-1.es.amazonaws.com:9200']

for endpoint in endpoints:
    try:
        es = Elasticsearch(endpoint)
        print es.count('analytics_v4')
    except Exception, e:
        print e
        print endpoint + " didn't work"

这是我当前的测试设置,我的IDE(pycharm)在此时完全停止,我需要结束运行才能再次尝试,我已经单独尝试了每个端点,但没有一个能够正常工作。

我的访问政策是:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": "*"
      },
      "Action": "es:*",
      "Resource": "arn:aws:es:us-east-1:MYIDdomain/analytics/*",
      "Condition": {
        "IpAddress": {
          "aws:SourceIp": [
            "MYIP"
          ]
        }
      }
    }
  ]
}

我收到错误:433: ConnectionError(HTTPConnectionPool(host='MYID.us-east-1.es.amazonaws.com', port=443): Max retries exceeded with url: /analytics_v4/_count (Caused by <class 'httplib.BadStatusLine'>: '')) caused by: MaxRetryError(HTTPConnectionPool(host='MYID.us-east-1.es.amazonaws.com', port=443): Max retries exceeded with url: /analytics_v4/_count (Caused by <class 'httplib.BadStatusLine'>: ''))

0 个答案:

没有答案