Windows环境下无法使用Elasticsearch _bulk API求助
Elasticsearch _bulk API 索引问题解决方法
错误原因1:引号格式不兼容
Windows CMD环境不支持用单引号(')包裹curl参数,单引号会被解析成参数的一部分,导致application被误识别为主机名,触发“无法解析主机: application”错误。Linux下常用的单引号在Windows CMD中必须替换为双引号(")。错误原因2:API路径拼写错误
命令中的_bluk是拼写错误,Elasticsearch批量API的正确路径为_bulk,拼写错误直接引发“URL格式非法”问题。
修正后的CMD命令
curl -k -H "Content-Type: application/x-ndjson" -X POST "https://localhost:9200/bank/_bulk?pretty" -d @accounts.json
PowerShell环境适配方案
PowerShell中@会被当作变量引用符号,需调整-d参数写法:
curl -k -H "Content-Type: application/x-ndjson" -X POST "https://localhost:9200/bank/_bulk?pretty" -d $(Get-Content accounts.json -Raw)
内容的提问来源于stack exchange,提问作者Tushar singh
相关产品推荐
相关产品推荐

