elasticsearch - curl “(6) Could not resolve host: http”

标签 elasticsearch curl

我正在尝试运行此命令

curl -XPUT -H "Content-Type: application/json" https://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'

但这导致此错误
curl: (6) Could not resolve host: http
curl: (3) unmatched close brace/bracket in URL position 5:
null}'

我从这里得到这个命令

https://stackoverflow.com/a/50609418/3259896

我对curl和elasticseach不太熟悉,所以我不确定如何查明错误

如果有帮助,我正在使用Windows。

我也试过
$ curl -X PUT -H "Content-Type: application/json" https://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'

编辑2:

我试过了
curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'
但是现在得到这个错误
{"error":{"root_cause":[{"type":"json_parse_exception","reason":"Unexpected character (''' (code 39)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@446f2dd5; line: 1, column: 2]"}],"type":"json_parse_exception","reason":"Unexpected character (''' (code 39)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@446f2dd5; line: 1, column: 2]"},"status":400}curl: (3) unmatched close brace/bracket in URL position 5: null}' ^
然后我尝试了
curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d "{"index.blocks.read_only_allow_delete": null}"
我得到了
{"error":{"root_cause":[{"type":"json_parse_exception","reason":"Unexpected character ('i' (code 105)): was expecting double-quote to start field name\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@696b36d3; line: 1, column: 3]"}],"type":"json_parse_exception","reason":"Unexpected character ('i' (code 105)): was expecting double-quote to start field name\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@696b36d3; line: 1, column: 3]"},"status":400}

最佳答案

首先,在另一个SO问题中,ES节点是一个实时节点,因此其URL包含https

您的本地主机ist几乎肯定不会有https,因此将其更改为http:

curl -XPUT -H "Content-Type: application/json" \
     http://localhost:9200/_all/_settings \
     -d '{"index.blocks.read_only_allow_delete": null}'

除此之外,只要您的ES正在运行,一切就可以了。

成功后,您应该会收到一条简单的消息:
{"acknowledged":true}

编辑:与
curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d "{\"index.blocks.read_only_allow_delete\": null}"

关于elasticsearch - curl “(6) Could not resolve host: http”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60961257/

相关文章:

elasticsearch - 无法用grok过滤日志

c# - 如何在 C# ApiController 中发送字节数组

php - 对站点的 cURL 请求返​​回空文档

java - 使用 Spring Data ElasticSearch 进行全文搜索

.net - Serilog + serilog-sinks-elasticsearch +ElasticSearch Auth

php - AWS SDK for PHP 可以在不禁用 osx 上的 SSL 验证的情况下工作吗?

php - 管理长时间运行的 php 脚本的最佳方法?

php - 如何在 PHP 中从 .pfx 证书获取 key.pem 和 crt.pem

elasticsearch - 如何确保所有文件在ElasticSearch中建立索引

elasticsearch - Elasticsearch 中 _search 的 "preference"和 "search_type"之间的结果差异