use of com.xiaomi.linden.thrift.common.LindenTermFilter in project linden by XiaoMi.
the class TestBQL method testDelete.
@Test
public void testDelete() {
String bql = "delete from linden where title = 'sed'";
LindenDeleteRequest lindenRequest = compiler.compile(bql).getDeleteRequest();
LindenTermFilter termFilter = new LindenTermFilter().setTerm(new LindenTerm().setField("title").setValue("sed"));
Assert.assertEquals(termFilter, lindenRequest.getQuery().getFilteredQuery().getLindenFilter().getTermFilter());
bql = "delete from linden";
lindenRequest = compiler.compile(bql).getDeleteRequest();
Assert.assertTrue(lindenRequest.getQuery().isSetMatchAllQuery());
bql = "delete from tag_1,tag_2";
lindenRequest = compiler.compile(bql).getDeleteRequest();
Assert.assertEquals(lindenRequest.getIndexNames().size(), 2);
Assert.assertEquals(lindenRequest.getIndexNames().get(0), "tag_1");
Assert.assertEquals(lindenRequest.getIndexNames().get(1), "tag_2");
bql = "delete from linden where id = '123' route by 1, 2, 3";
lindenRequest = compiler.compile(bql).getDeleteRequest();
Assert.assertTrue(lindenRequest.getQuery().isSetFilteredQuery());
Assert.assertEquals(3, lindenRequest.getRouteParam().getShardParamsSize());
Assert.assertEquals(1, lindenRequest.getRouteParam().getShardParams().get(0).getShardId());
Assert.assertEquals(2, lindenRequest.getRouteParam().getShardParams().get(1).getShardId());
}
Aggregations