use of com.xiaomi.linden.thrift.common.LindenBooleanSubFilter in project linden by XiaoMi.
the class TestBQL method testNotEqualPred.
@Test
public void testNotEqualPred() throws Exception {
String bql = "SELECT * FROM linden WHERE title <> 'red'";
LindenSearchRequest lindenRequest = compiler.compile(bql).getSearchRequest();
LindenBooleanFilter booleanFilter = new LindenBooleanFilter();
LindenFilter termFilter = LindenTermFilterBuilder.buildTermFilter("title", "red");
booleanFilter.addToFilters(new LindenBooleanSubFilter().setFilter(termFilter).setClause(LindenBooleanClause.MUST_NOT));
Assert.assertEquals(booleanFilter, lindenRequest.getFilter().getBooleanFilter());
bql = "SELECT * FROM linden WHERE title <> 're''d'";
lindenRequest = compiler.compile(bql).getSearchRequest();
booleanFilter = new LindenBooleanFilter();
termFilter = LindenTermFilterBuilder.buildTermFilter("title", "re'd");
booleanFilter.addToFilters(new LindenBooleanSubFilter().setFilter(termFilter).setClause(LindenBooleanClause.MUST_NOT));
Assert.assertEquals(booleanFilter, lindenRequest.getFilter().getBooleanFilter());
bql = "SELECT * FROM linden WHERE id <> 2000";
lindenRequest = compiler.compile(bql).getSearchRequest();
booleanFilter = new LindenBooleanFilter();
LindenFilter rangeFilter = LindenRangeFilterBuilder.buildRangeFilter("id", LindenType.LONG, "2000", "2000", true, true);
booleanFilter.addToFilters(new LindenBooleanSubFilter().setFilter(rangeFilter).setClause(LindenBooleanClause.MUST_NOT));
Assert.assertEquals(booleanFilter, lindenRequest.getFilter().getBooleanFilter());
bql = "SELECT * FROM linden WHERE id <> $id";
lindenRequest = compiler.compile(bql).getSearchRequest();
Assert.assertEquals(null, lindenRequest.getFilter());
bql = "SELECT * FROM linden BY title <> 're''d'";
lindenRequest = compiler.compile(bql).getSearchRequest();
LindenBooleanQueryBuilder builder = new LindenBooleanQueryBuilder();
builder.addQuery(LindenRangeQueryBuilder.buildMatchAllQuery(), LindenBooleanClause.MUST);
builder.addQuery(LindenRangeQueryBuilder.buildTermQuery("title", "re'd"), LindenBooleanClause.MUST_NOT);
Assert.assertEquals(builder.build(), lindenRequest.getQuery());
bql = "SELECT * FROM linden BY id <> $id";
lindenRequest = compiler.compile(bql).getSearchRequest();
Assert.assertEquals(LindenQueryBuilder.buildMatchAllQuery(), lindenRequest.getQuery());
}
Aggregations