ES curl请求报错:文章来源:https://www.toymoban.com/news/detail-502340.html
curl -X GET "localhost:9200/megacorp/employee/_search?q=last_name:Smith&pretty"
{
"error" : {
"root_cause" : [
{
"type" : "security_exception",
"reason" : "missing authentication credentials for REST request [/megacorp/employee/_search?q=last_name:Smith&pretty]",
"header" : {
"WWW-Authenticate" : "Basic realm=\"security\" charset=\"UTF-8\""
}
}
],
"type" : "security_exception",
"reason" : "missing authentication credentials for REST request [/megacorp/employee/_search?q=last_name:Smith&pretty]",
"header" : {
"WWW-Authenticate" : "Basic realm=\"security\" charset=\"UTF-8\""
}
},
"status" : 401
}
原因: ES配置了密码认证,curl发起请求的时候需要带上认证信息文章来源地址https://www.toymoban.com/news/detail-502340.html
curl --user elastic:password -X GET "localhost:9200/megacorp/employee/_search?q=last_name:Smith&pretty"
{
"took" : 4,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 2,
"relation" : "eq"
},
"max_score" : 0.35667494,
"hits" : [
{
"_index" : "megacorp",
"_type" : "employee",
"_id" : "2",
"_score" : 0.35667494,
"_source" : {
"first_name" : "Jane",
"last_name" : "Smith",
"age" : 32,
"about" : "I like to collect rock albums",
"interests" : [
"music"
]
}
},
{
"_index" : "megacorp",
"_type" : "employee",
"_id" : "1",
"_score" : 0.35667494,
"_source" : {
"first_name" : "John",
"last_name" : "Smith",
"age" : 27,
"about" : "I love to go rock climbing",
"interests" : [
"sports",
"music"
]
}
}
]
}
}
到了这里,关于missing authentication credentials for REST request的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!