我沉浸在 Elastic Search 的 2 小时中。我用 Marvel 成功安装了 ES(marvel.agent.enabled: false
在 config/elasticsearch.yml 中),并且能够从 Sense 发出成功的请求。我重新启动了我的开发机器,现在当我在 Sense 上发出以下请求时,它会响应:
Request failed to get to the server (status code: 0):
Elasticsearch may not be reachable or you may need to check your CORS settings.If CORS is enabled, try turning off Sense's Basic Authentication support under Setting (cog icon).This will result in a less strict CORS enforcement by the browser.
Please check the marvel documentation for more information.
请求(来源):
PUT /megacorp/employee/1
{
"first_name" : "John",
"last_name" : "Smith",
"age" : 25,
"about" : "I love to go rock climbing",
"interests": [ "sports", "music" ]
}
按照指示,我通过在 curl 上发出类似请求来检查 ES 是否可访问:
要求:
curl -XPUT http://localhost:9200/megacorp/employee/100 -d '{ "first_name" : "test" }'
回复:
{"_index":"megacorp","_type":"employee","_id":"100","_version":1,"created":true}
这让我认为 ES 是可用的。
继续下一项检查“您可能需要检查您的 CORS 设置。”。我根据此建议将以下配置添加到 elasticsearch.yml(并重新启动 ES) :
http.cors.enabled: true
http.cors.allow-origin: /.*/
http.cors.allow-credentials: true
但是行为没有变化。
在 Marvel/Smart 设置中切换“支持基本身份验证”也没有影响。
欢迎任何关于可能出现问题的指示。