从Apache Calcite向安全的Elastisearch服务器(https)执行查询

时间:2019-07-04 22:02:33

标签: apache apache-calcite

如何在model.json文件中表示方案(https),这是用于连接Elasticsearch?

以下是model.js文件:

{
  "version": "1.0",
  "defaultSchema": "elasticsearch",
  "schemas": [
    {
      "type": "custom",
      "name": "elasticsearch",
      "factory": "org.apache.calcite.adapter.elasticsearch.ElasticsearchSchemaFactory",
      "operand": {
        "coordinates": "{'127.0.0.1': 9200}",
        "index": "myIndex",
        "useConig": "{}"
      }
    }
  ]
}

在下面的Java代码中,我试图连接到Elasticsearch:

Connection conn = DriverManager.getConnection("jdbc:calcite:", properties);
calciteConnection = conn.unwrap(CalciteConnection.class);
String elasticSchema = Resources.toString(somefile.class.getResource("/model.json"), Charset.defaultCharset());

new ModelHandler(calciteConnection, "inline:" + elasticSchema);

String sql = “select field1 from table1”
statement2 = calciteConnection.prepareStatement(sql);
ResultSet set = statement2.executeQuery();

获取连接关闭异常,我在日志中看到它正在尝试连接到HTTP,而不是https(需要)。我在模型文件中哪里提到https?

1 个答案:

答案 0 :(得分:0)

Calcite的Elasticsearch适配器当前不支持通过HTTPS进行连接。建议您在Calcite's JIRA上提出一个问题。或者更好的是,自己贡献必要的代码更改:)