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());
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations