我正在尝试使用Apache Calcite连接到ElasticSearch,但在设置用户名密码时遇到问题。
我尝试过使用operand(基于JSON)、属性(DriverManager.getConnection(String url, Properties config))和DriverManager.getConnection(String url, username, password)来配置用户名/密码,但它们都不能正常工作。
我之前已经把这个问题发到了Apache JIRA上
我的代码如下
正在尝试使用属性设置用户名和密码
Properties config = new Properties();
config.put("lex", "JAVA");
String sql = "select * from index";
try (Connection con = DriverManager.getConnection("jdbc:calcite:model=src/main/resources/es.json", config)) {
try (Statement stmt = con.createStatement()) {
try (ResultSet rs = stmt.executeQuery(sql)) {
printRs(rs);
}
}
}尝试使用操作数设置它
{
"version": "1.0",
"defaultSchema": "elasticsearch",
"schemas": [
{
"type": "custom",
"name": "elasticsearch",
"factory": "org.apache.calcite.adapter.elasticsearch.ElasticsearchSchemaFactory",
"operand": {
"coordinates": "{'192.168.133.104': 9200}",
"jdbcUser": "elastic",
"jdbcPassword": "elastic"
}
}
]
}并抛出异常
{
"error":{
"root_cause":[
{
"type":"security_exception",
"reason":"missing authentication token for REST request [/_alias]",
"header":{
"WWW-Authenticate":"Basic realm="security" charset="UTF-8""
}
}
],
"type":"security_exception",
"reason":"missing authentication token for REST request [/_alias]",
"header":{
"WWW-Authenticate":"Basic realm="security" charset="UTF-8""
}
},
"status":401
}发布于 2020-09-04 21:57:09
在这个问题提出的时候,这是不可能的,但是这个功能has since been added,并将包括在下一个版本的方解石(1.26.0)中。除了配置中的coordinates密钥之外,您还可以添加username和password来指定身份验证参数。
https://stackoverflow.com/questions/63560137
复制相似问题