use of com.xiaomi.linden.thrift.common.LindenResult in project linden by XiaoMi.
the class TestLindenFacet method facetTest7.
// test with delete
@Test
public void facetTest7() throws Exception {
LindenSearchRequest request = new LindenSearchRequest();
LindenResult result = lindenCore.search(request);
Assert.assertEquals(13, result.getTotalHits());
handleRequest(generateDeleteRequest("1"));
lindenCore.commit();
lindenCore.refresh();
String bql = "select * from Linden browse by Author, PublishDate";
request = bqlCompiler.compile(bql).getSearchRequest();
result = lindenCore.search(request);
Assert.assertEquals(12, result.getTotalHits());
Assert.assertEquals(2, result.getFacetResultsSize());
// Author facet
Assert.assertEquals("LindenFacetResult(dim:Author, value:10, childCount:4, " + "labelValues:[LindenLabelAndValue(label:Lisa, value:4), " + "LindenLabelAndValue(label:Susan, value:4), " + "LindenLabelAndValue(label:Bob, value:1), " + "LindenLabelAndValue(label:Frank, value:1)])", result.getFacetResults().get(0).toString());
// PublishDate facet
Assert.assertEquals("LindenFacetResult(dim:PublishDate, value:10, childCount:4, " + "labelValues:[LindenLabelAndValue(label:2010, value:3), " + "LindenLabelAndValue(label:2012, value:3), " + "LindenLabelAndValue(label:1999, value:3), " + "LindenLabelAndValue(label:2013, value:1)])", result.getFacetResults().get(1).toString());
handleRequest(generateIndexRequest("1", "cn", "Bob book 1", "Bob", "2010/10/15"));
lindenCore.commit();
lindenCore.refresh();
}
use of com.xiaomi.linden.thrift.common.LindenResult in project linden by XiaoMi.
the class TestLindenFacet method facetTest6.
// Early termination
@Test
public void facetTest6() 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 in top 5";
request = bqlCompiler.compile(bql).getSearchRequest();
result = lindenCore.search(request);
Assert.assertEquals(5, result.getTotalHits());
Assert.assertEquals(2, result.getFacetResultsSize());
// Author facet
Assert.assertEquals("LindenFacetResult(dim:Author, value:5, childCount:4, " + "labelValues:[LindenLabelAndValue(label:Lisa, value:2), LindenLabelAndValue(label:Bob, value:1), " + "LindenLabelAndValue(label:Susan, value:1), LindenLabelAndValue(label:Frank, value:1)])", result.getFacetResults().get(0).toString());
// PublishDate facet
Assert.assertEquals("LindenFacetResult(dim:PublishDate, value:5, childCount:3, " + "labelValues:[LindenLabelAndValue(label:2010, value:2), " + "LindenLabelAndValue(label:2012, value:2), " + "LindenLabelAndValue(label:1999, value:1)])", result.getFacetResults().get(1).toString());
}
use of com.xiaomi.linden.thrift.common.LindenResult in project linden by XiaoMi.
the class TestLindenFacet method facetTest3.
// test with query and filter
@Test
public void facetTest3() throws Exception {
LindenSearchRequest request = new LindenSearchRequest();
LindenResult result = lindenCore.search(request);
Assert.assertEquals(13, result.getTotalHits());
String bql = "select * from linden by query is 'Title:Lisa' where Language='en' browse by Author, PublishDate";
request = bqlCompiler.compile(bql).getSearchRequest();
result = lindenCore.search(request);
Assert.assertEquals(2, result.getTotalHits());
Assert.assertEquals(2, result.getFacetResultsSize());
// Author facet
Assert.assertEquals("LindenFacetResult(dim:Author, value:2, childCount:1, " + "labelValues:[LindenLabelAndValue(label:Lisa, value:2)])", result.getFacetResults().get(0).toString());
// PublishDate facet
Assert.assertEquals("LindenFacetResult(dim:PublishDate, value:2, childCount:1, " + "labelValues:[LindenLabelAndValue(label:2012, value:2)])", result.getFacetResults().get(1).toString());
}
use of com.xiaomi.linden.thrift.common.LindenResult in project linden by XiaoMi.
the class TestLindenFieldCache method intListTest.
@Test
public void intListTest() throws IOException {
String bql = "select * from linden by query is \"title:lucene\" " + "using score model test " + "begin " + " float sum = 0;\n" + " for (int a : ids_int()) {\n" + " sum += a;\n" + " }\n" + " return sum;\n" + "end";
LindenSearchRequest request = bqlCompiler.compile(bql).getSearchRequest();
LindenResult result = lindenCore.search(request);
Assert.assertEquals(10, result.getTotalHits());
Assert.assertEquals(30, result.getHits().get(0).getScore(), 0.1f);
bql = "select * from linden where ids_int = 2 " + "using score model test " + "begin " + " float sum = 0;\n" + " for (int a : ids_int()) {\n" + " sum += a;\n" + " }\n" + " return sum;\n" + "end";
request = bqlCompiler.compile(bql).getSearchRequest();
result = lindenCore.search(request);
Assert.assertEquals(3, result.getTotalHits());
Assert.assertEquals(9, result.getHits().get(0).getScore(), 0.1f);
}
use of com.xiaomi.linden.thrift.common.LindenResult in project linden by XiaoMi.
the class TestLindenGroupSearch method groupSearchTest3.
// dynamic field
@Test
public void groupSearchTest3() throws IOException {
String bql = "select * from linden order by rank group by cat1.STRING TOP 3 limit 0,10 source";
LindenSearchRequest request = bqlCompiler.compile(bql).getSearchRequest();
Assert.assertEquals(true, request.isSetGroupParam());
Assert.assertEquals("cat1", request.getGroupParam().getGroupField());
Assert.assertEquals(3, request.getGroupParam().getGroupInnerLimit());
LindenResult result = lindenCore.search(request);
Assert.assertEquals(true, result.isSuccess());
Assert.assertEquals(5, result.getTotalHits());
Assert.assertEquals(3, result.getTotalGroups());
Assert.assertEquals(3, result.getHitsSize());
Assert.assertEquals(2, result.getHits().get(0).getGroupHitsSize());
Assert.assertEquals("10.3", result.getHits().get(0).getGroupHits().get(0).getFields().get("rank"));
Assert.assertEquals("4.5", result.getHits().get(0).getGroupHits().get(1).getFields().get("rank"));
Assert.assertEquals(1, result.getHits().get(1).getGroupHitsSize());
Assert.assertEquals("10.0", result.getHits().get(1).getGroupHits().get(0).getFields().get("rank"));
Assert.assertEquals(2, result.getHits().get(2).getGroupHitsSize());
Assert.assertEquals("4.0", result.getHits().get(2).getGroupHits().get(0).getFields().get("rank"));
Assert.assertEquals("1.2", result.getHits().get(2).getGroupHits().get(1).getFields().get("rank"));
}
Aggregations