Search in sources :

Example 26 with LindenSearchRequest

use of com.xiaomi.linden.thrift.common.LindenSearchRequest in project linden by XiaoMi.

the class TestLindenFacet method facetTest4.

// Drill down
@Test
public void facetTest4() throws Exception {
    LindenSearchRequest request = new LindenSearchRequest();
    LindenResult result = lindenCore.search(request);
    Assert.assertEquals(13, result.getTotalHits());
    String bql = "select * from Linden browse by Author, PublishDate drill down PublishDate('2010')";
    request = bqlCompiler.compile(bql).getSearchRequest();
    result = lindenCore.search(request);
    Assert.assertEquals(4, result.getTotalHits());
    Assert.assertEquals(2, result.getFacetResultsSize());
    // Author facet
    Assert.assertEquals("LindenFacetResult(dim:Author, value:4, childCount:2, " + "labelValues:[LindenLabelAndValue(label:Bob, value:2), LindenLabelAndValue(label:Lisa, value:2)])", result.getFacetResults().get(0).toString());
    // PublishDate facet
    Assert.assertEquals("LindenFacetResult(dim:PublishDate, value:4, childCount:1, labelValues:[LindenLabelAndValue(label:2010, value:4)])", result.getFacetResults().get(1).toString());
}
Also used : LindenResult(com.xiaomi.linden.thrift.common.LindenResult) LindenSearchRequest(com.xiaomi.linden.thrift.common.LindenSearchRequest) Test(org.junit.Test)

Example 27 with LindenSearchRequest

use of com.xiaomi.linden.thrift.common.LindenSearchRequest in project linden by XiaoMi.

the class TestLindenFieldCache method idTest.

@Test
public void idTest() throws IOException {
    String bql = "select * from linden by query is \"title:lucene\" " + "using score model test " + "begin " + "  String expectedId = \"doc_\" + doc();\n" + "  if (!id().equals(expectedId)) {\n" + "      return -1.0;\n" + "  }\n" + "return 1.0;\n" + "end";
    LindenSearchRequest request = bqlCompiler.compile(bql).getSearchRequest();
    LindenResult result = lindenCore.search(request);
    Assert.assertEquals(10, result.getTotalHits());
    for (int i = 0; i < 10; ++i) {
        Assert.assertTrue(result.getHits().get(i).score > 0.0);
    }
}
Also used : LindenResult(com.xiaomi.linden.thrift.common.LindenResult) LindenSearchRequest(com.xiaomi.linden.thrift.common.LindenSearchRequest) Test(org.junit.Test)

Example 28 with LindenSearchRequest

use of com.xiaomi.linden.thrift.common.LindenSearchRequest in project linden by XiaoMi.

the class TestLindenFieldCache method floatListTest.

@Test
public void floatListTest() throws IOException {
    String bql = "select * from linden by query is \"title:lucene\" " + "using score model test " + "begin " + "  int base = doc();\n" + "  for (float f : ids_float()) {\n" + "    if (f != (float)(base++)) {\n" + "      return -1.0;\n" + "    }\n" + "  }\n" + "  return 1.0;\n" + "end";
    LindenSearchRequest request = bqlCompiler.compile(bql).getSearchRequest();
    LindenResult result = lindenCore.search(request);
    Assert.assertEquals(10, result.getTotalHits());
    for (int i = 0; i < 10; ++i) {
        Assert.assertTrue(result.getHits().get(i).score > 0.0);
    }
}
Also used : LindenResult(com.xiaomi.linden.thrift.common.LindenResult) LindenSearchRequest(com.xiaomi.linden.thrift.common.LindenSearchRequest) Test(org.junit.Test)

Example 29 with LindenSearchRequest

use of com.xiaomi.linden.thrift.common.LindenSearchRequest in project linden by XiaoMi.

the class TestLindenFieldCache method stringListTest.

@Test
public void stringListTest() throws IOException {
    String bql = "select * from linden by query is \"title:lucene\" " + "using score model test " + "begin " + "  int base = doc();\n" + "  for (String str : ids_str()) {\n" + "    if (base++ != Integer.valueOf(str)) {\n" + "      return -1.0;\n" + "    }\n" + "  }\n" + "  return 1.0;\n" + "end";
    LindenSearchRequest request = bqlCompiler.compile(bql).getSearchRequest();
    LindenResult result = lindenCore.search(request);
    Assert.assertEquals(10, result.getTotalHits());
    for (int i = 0; i < 10; ++i) {
        Assert.assertTrue(result.getHits().get(i).score > 0.0);
    }
}
Also used : LindenResult(com.xiaomi.linden.thrift.common.LindenResult) LindenSearchRequest(com.xiaomi.linden.thrift.common.LindenSearchRequest) Test(org.junit.Test)

Example 30 with LindenSearchRequest

use of com.xiaomi.linden.thrift.common.LindenSearchRequest in project linden by XiaoMi.

the class TestLindenFieldCache method doubleListTest.

@Test
public void doubleListTest() throws IOException {
    String bql = "select * from linden by query is \"title:lucene\" " + "using score model test " + "begin " + "  int base = doc();\n" + "  for (double d : ids_double()) {\n" + "    if (d != (double)(base++)) {\n" + "      return -1.0;\n" + "    }\n" + "  }\n" + "  return 1.0;\n" + "end";
    LindenSearchRequest request = bqlCompiler.compile(bql).getSearchRequest();
    LindenResult result = lindenCore.search(request);
    Assert.assertEquals(10, result.getTotalHits());
    for (int i = 0; i < 10; ++i) {
        Assert.assertTrue(result.getHits().get(i).score > 0.0);
    }
}
Also used : LindenResult(com.xiaomi.linden.thrift.common.LindenResult) LindenSearchRequest(com.xiaomi.linden.thrift.common.LindenSearchRequest) Test(org.junit.Test)

Aggregations

LindenSearchRequest (com.xiaomi.linden.thrift.common.LindenSearchRequest)95 Test (org.junit.Test)90 LindenResult (com.xiaomi.linden.thrift.common.LindenResult)69 LindenQuery (com.xiaomi.linden.thrift.common.LindenQuery)13 LindenFilter (com.xiaomi.linden.thrift.common.LindenFilter)9 LindenBooleanQueryBuilder (com.xiaomi.linden.thrift.builder.query.LindenBooleanQueryBuilder)5 LindenBooleanFilter (com.xiaomi.linden.thrift.common.LindenBooleanFilter)5 IOException (java.io.IOException)5 JSONObject (com.alibaba.fastjson.JSONObject)4 LindenBooleanSubFilter (com.xiaomi.linden.thrift.common.LindenBooleanSubFilter)4 LindenDeleteRequest (com.xiaomi.linden.thrift.common.LindenDeleteRequest)4 LindenScoreModel (com.xiaomi.linden.thrift.common.LindenScoreModel)4 Stopwatch (com.google.common.base.Stopwatch)3 MultiLindenCoreImpl (com.xiaomi.linden.core.search.MultiLindenCoreImpl)3 LindenFlexibleQueryBuilder (com.xiaomi.linden.thrift.builder.query.LindenFlexibleQueryBuilder)3 LindenFacet (com.xiaomi.linden.thrift.common.LindenFacet)3 LindenFacetDimAndPath (com.xiaomi.linden.thrift.common.LindenFacetDimAndPath)3 LindenFacetParam (com.xiaomi.linden.thrift.common.LindenFacetParam)3 LindenRequest (com.xiaomi.linden.thrift.common.LindenRequest)3 LindenTerm (com.xiaomi.linden.thrift.common.LindenTerm)3