use of com.xiaomi.linden.thrift.builder.query.LindenQueryStringQueryBuilder in project linden by XiaoMi.
the class BQLCompilerAnalyzer method exitQuery_predicate.
@Override
public void exitQuery_predicate(BQLParser.Query_predicateContext ctx) {
String orig = unescapeStringLiteral(ctx.STRING_LITERAL());
LindenQueryStringQueryBuilder builder = new LindenQueryStringQueryBuilder().setQuery(orig);
if (ctx.disable_coord != null) {
builder.setDisableCoord((Boolean) valProperty.get(ctx.disable_coord));
}
if (ctx.AND() != null) {
builder.setOperator(Operator.AND);
}
LindenQuery stringQuery = builder.build();
if (inQueryWhere) {
queryProperty.put(ctx, stringQuery);
} else {
LindenFilter filter = LindenQueryFilterBuilder.buildQueryFilter(stringQuery);
filterProperty.put(ctx, filter);
}
}
use of com.xiaomi.linden.thrift.builder.query.LindenQueryStringQueryBuilder in project linden by XiaoMi.
the class TestBQL method testQueryPredicate.
@Test
public void testQueryPredicate() {
String bql = "select * from linden where query is 'title:a' and id = 233";
LindenSearchRequest lindenRequest = compiler.compile(bql).getSearchRequest();
Assert.assertTrue(lindenRequest.getFilter().isSetBooleanFilter());
Assert.assertEquals(2, lindenRequest.getFilter().getBooleanFilter().getFilters().size());
Assert.assertTrue(lindenRequest.getFilter().getBooleanFilter().getFilters().get(0).getFilter().isSetQueryFilter());
bql = "select * from linden by query is 'abc' and query is 'def' where id = 1 or id = 3";
lindenRequest = compiler.compile(bql).getSearchRequest();
Assert.assertTrue(lindenRequest.getQuery().isSetBooleanQuery());
Assert.assertEquals(2, lindenRequest.getQuery().getBooleanQuery().getQueriesSize());
Assert.assertTrue(lindenRequest.getFilter().isSetBooleanFilter());
Assert.assertEquals(2, lindenRequest.getFilter().getBooleanFilter().getFilters().size());
bql = "select * from linden by query is 'title:abc bcd' disableCoord OP(AND)";
lindenRequest = compiler.compile(bql).getSearchRequest();
LindenQueryStringQueryBuilder builder = new LindenQueryStringQueryBuilder();
builder.setQuery("title:abc bcd").setOperator(Operator.AND);
builder.setDisableCoord(true);
LindenQuery expected = builder.build();
Assert.assertEquals(expected, lindenRequest.getQuery());
}
Aggregations