APACHE钙|使用RelNode

时间:2019-05-30 11:22:31

标签: java elasticsearch apache-calcite

我想使用RelNode对象而不是传统的SQL查询方法在Elasticsearch上执行搜索操作。

我尝试通过提供投影和滤镜来构建RelNode对象,但是说没有找到输入字段,这没有用。

   SchemaPlus postschema = con.getRootSchema().getSubSchema("twitter2");

    FrameworkConfig postConfig = Frameworks.newConfigBuilder()
            .defaultSchema(postschema)
            .build();
    RelBuilder postBuilder = RelBuilder.create(postConfig);

   RelNode relSelect = postBuilder.scan("user").project(testBuilder.scan("user").field("name)).build();

我使用了以下架构:

+ "{
"
                    + "  version: '1.0',
"
                    + "  defaultSchema: 'BASEJDBC',
"
                    + "  schemas: [
"
                    + "     {
"
                    + "       type: 'custom',
"
                    + "       name: 'twitter2',
"
                    + "       factory: '" + "org.apache.calcite.adapter.elasticsearch.ElasticsearchSchemaFactory" + "',
"
                    + "       operand:  { 
"
                    + "         "coordinates": " + " "{'localhost': 9200}",
 "
                    + "         "userConfig": " + " "{'admin': 'admin'}",
 "
                    + "         "index":  "twitter2" 
"
                    + "       }
"
                    + "     },
"

我可以使用过滤器中的以下RexNode对象来获取正确的结果集:

   final RexNode condition1 =
            rexbuilder.makeCall(SqlStdOperatorTable.EQUALS,
                            rexbuilder.makeCall(SqlStdOperatorTable.ITEM,rexbuilder.makeInputRef(relDataTypeFactory.createSqlType(SqlTypeName.ANY), 0),
                                    rexbuilder.makeLiteral("_id"))
                    ,
                    rexbuilder.makeLiteral("ss")
            );



 RelNode node = postBuilder.scan("user")
          .filter(condition1)
            //.project()
            .build();

仍然无法创建投影RelNode对象。 这是创建过滤器RelNode对象的标准方法吗?

您能否在查看时提供详细信息以及如何将其用于查询构建?

0 个答案:

没有答案