我有一个在 EC2 服务器上运行的 Elasticsearch 集群。当我尝试连接时,我收到各种不同的错误消息。目前,在 elasticsearch.yml 文件中,所有传输项都被注释掉了,但我已经尝试过:network.host: 0.0.0.0andnetwork.host: ec2-xx-xxx-xxx.aws.instance.com在我的烧瓶应用程序中,代码如下:from datetime import datetimefrom flask import Flask, jsonify, requestfrom elasticsearch import Elasticsearch#es = Elasticsearch()http://34.245.51.240/es = Elasticsearch(['ec2-34-xxx-xx-240.eu-west-1.compute.amazonaws.com','9200'])#es = Elasticsearch(['34.245.51.240','9200'])application = Flask(__name__)@application.route('/', methods=['GET'])def index(): #results = es.get(index='contents', doc_type='title', id='my-new-slug') #return jsonify(results['_source']) doc = { 'author': 'kimchy', 'text': 'Elasticsearch: cool. bonsai cool.', 'timestamp': datetime.now(), } res = es.index(index="test-index", doc_type='tweet', id=1, body=doc) print(res['res']) return res#application.run(port=5000, debug=True)if __name__ == '__main__': application.debug = True application.run()我用谷歌搜索了很多次,并尝试了我能找到的所有可能的配置。实现这一目标的正确方法是什么?
添加回答
举报
0/150
提交
取消