Search in sources :

Example 1 with LindenTermFilter

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());
}
Also used : LindenDeleteRequest(com.xiaomi.linden.thrift.common.LindenDeleteRequest) LindenTermFilter(com.xiaomi.linden.thrift.common.LindenTermFilter) LindenTerm(com.xiaomi.linden.thrift.common.LindenTerm) Test(org.junit.Test)

Aggregations

LindenDeleteRequest (com.xiaomi.linden.thrift.common.LindenDeleteRequest)1 LindenTerm (com.xiaomi.linden.thrift.common.LindenTerm)1 LindenTermFilter (com.xiaomi.linden.thrift.common.LindenTermFilter)1 Test (org.junit.Test)1