我想使用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对象的标准方法吗?
您能否在查看时提供详细信息以及如何将其用于查询构建?