Search in sources :

Example 11 with LindenResult

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

the class TestLindenCore method notEqualTest.

@Test
public void notEqualTest() throws Exception {
    String bql = "select * from linden where id <> '3'";
    LindenSearchRequest request = bqlCompiler.compile(bql).getSearchRequest();
    LindenResult result = lindenCore.search(request);
    Assert.assertEquals(5, result.getTotalHits());
    bql = "select * from linden where field1 <> 'aaa'";
    request = bqlCompiler.compile(bql).getSearchRequest();
    result = lindenCore.search(request);
    Assert.assertEquals(5, result.getTotalHits());
    bql = "select * from linden by field1 <> 'aaa'";
    request = bqlCompiler.compile(bql).getSearchRequest();
    result = lindenCore.search(request);
    Assert.assertEquals(5, result.getTotalHits());
}
Also used : LindenResult(com.xiaomi.linden.thrift.common.LindenResult) LindenSearchRequest(com.xiaomi.linden.thrift.common.LindenSearchRequest) Test(org.junit.Test)

Example 12 with LindenResult

use of com.xiaomi.linden.thrift.common.LindenResult 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 13 with LindenResult

use of com.xiaomi.linden.thrift.common.LindenResult 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 14 with LindenResult

use of com.xiaomi.linden.thrift.common.LindenResult 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 15 with LindenResult

use of com.xiaomi.linden.thrift.common.LindenResult 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)

Aggregations

LindenResult (com.xiaomi.linden.thrift.common.LindenResult)79 LindenSearchRequest (com.xiaomi.linden.thrift.common.LindenSearchRequest)69 Test (org.junit.Test)69 IOException (java.io.IOException)7 LindenQuery (com.xiaomi.linden.thrift.common.LindenQuery)5 JSONObject (com.alibaba.fastjson.JSONObject)4 Stopwatch (com.google.common.base.Stopwatch)4 MultiLindenCoreImpl (com.xiaomi.linden.core.search.MultiLindenCoreImpl)3 LindenFlexibleQueryBuilder (com.xiaomi.linden.thrift.builder.query.LindenFlexibleQueryBuilder)3 LindenDeleteRequest (com.xiaomi.linden.thrift.common.LindenDeleteRequest)3 LindenHit (com.xiaomi.linden.thrift.common.LindenHit)3 LindenRequest (com.xiaomi.linden.thrift.common.LindenRequest)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 FlexibleQuery (com.xiaomi.linden.lucene.query.flexiblequery.FlexibleQuery)2 Response (com.xiaomi.linden.thrift.common.Response)2 BooleanQuery (org.apache.lucene.search.BooleanQuery)2 DisjunctionMaxQuery (org.apache.lucene.search.DisjunctionMaxQuery)2 FilteredQuery (org.apache.lucene.search.FilteredQuery)2 Query (org.apache.lucene.search.Query)2