use of com.xiaomi.linden.thrift.common.LindenResult in project linden by XiaoMi.
the class TestLindenFacet method facetTest9.
// test facet field index as normal field
@Test
public void facetTest9() throws Exception {
String bql = "select * from Linden where Author in ('Bob', 'Frank') source";
LindenSearchRequest request = bqlCompiler.compile(bql).getSearchRequest();
LindenResult result = lindenCore.search(request);
Assert.assertEquals(3, result.getHitsSize());
bql = "select * from Linden where Author not in ('Bob', 'Frank') source";
request = bqlCompiler.compile(bql).getSearchRequest();
result = lindenCore.search(request);
Assert.assertEquals(10, result.getHitsSize());
bql = "select * from Linden query Author = 'Susan' source";
request = bqlCompiler.compile(bql).getSearchRequest();
result = lindenCore.search(request);
Assert.assertEquals(4, result.getHitsSize());
bql = "select * from Linden where Author > 'A' and Author < 'G' source";
// Bob and Frank
request = bqlCompiler.compile(bql).getSearchRequest();
result = lindenCore.search(request);
Assert.assertEquals(3, result.getHitsSize());
bql = "select * from Linden where Author is null source";
request = bqlCompiler.compile(bql).getSearchRequest();
result = lindenCore.search(request);
Assert.assertEquals(2, result.getHitsSize());
bql = "select * from Linden where Author is not null source";
request = bqlCompiler.compile(bql).getSearchRequest();
result = lindenCore.search(request);
Assert.assertEquals(10, result.getHitsSize());
}
use of com.xiaomi.linden.thrift.common.LindenResult in project linden by XiaoMi.
the class TestLindenFacet method facetTest10.
// dynamic field
@Test
public void facetTest10() throws Exception {
String bql = "select * from Linden browse by Author.FACET, PublishDate.facet source";
LindenSearchRequest request = bqlCompiler.compile(bql).getSearchRequest();
LindenResult result = lindenCore.search(request);
Assert.assertEquals(13, result.getTotalHits());
Assert.assertEquals(2, result.getFacetResultsSize());
Assert.assertEquals("LindenHit(id:1, score:1.0, source:{\"PublishDate\":\"2010/10/15\",\"Language\":\"cn\",\"Author\":\"Bob\",\"id\":\"1\"})", result.getHits().get(0).toString());
bql = "select Author from Linden browse by Author, PublishDate source";
request = bqlCompiler.compile(bql).getSearchRequest();
result = lindenCore.search(request);
Assert.assertEquals(result.getHits().get(0).toString(), "LindenHit(id:1, score:1.0, source:{\"Author\":\"Bob\",\"id\":\"1\"})");
bql = "select * from Linden browse by Author.FACET, PublishDate.FACET drill down PublishDate.FACET('2010')";
request = bqlCompiler.compile(bql).getSearchRequest();
result = lindenCore.search(request);
Assert.assertEquals(4, result.getTotalHits());
Assert.assertEquals(2, result.getFacetResultsSize());
// PublishDate facet
Assert.assertEquals("LindenFacetResult(dim:PublishDate, value:4, childCount:1, labelValues:[LindenLabelAndValue(label:2010, value:4)])", result.getFacetResults().get(1).toString());
bql = "select * from Linden browse by Author.FACET, PublishDate.FACET drill sideways PublishDate.FACET('2010')";
request = bqlCompiler.compile(bql).getSearchRequest();
result = lindenCore.search(request);
Assert.assertEquals(4, result.getTotalHits());
Assert.assertEquals(2, result.getFacetResultsSize());
// PublishDate facet is not effected by drill down Path
Assert.assertEquals("LindenFacetResult(dim:PublishDate, value:11, childCount:4, " + "labelValues:[LindenLabelAndValue(label:2010, value:4), LindenLabelAndValue(label:2012, value:3), " + "LindenLabelAndValue(label:1999, value:3), LindenLabelAndValue(label:2013, value:1)])", result.getFacetResults().get(1).toString());
}
use of com.xiaomi.linden.thrift.common.LindenResult in project linden by XiaoMi.
the class TestLindenFacet method facetTest1.
// No query, no filter
@Test
public void facetTest1() 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, PublishDate(2), PublishDate(10, '2010'), " + "PublishDate(10, '2010/10'), PublishDate(10, '2010/10/15')," + "PublishDate(10, '2010/13'), Author(10, 'non-existent-path')";
request = bqlCompiler.compile(bql).getSearchRequest();
result = lindenCore.search(request);
Assert.assertEquals(13, result.getTotalHits());
Assert.assertEquals(8, result.getFacetResultsSize());
// Author facet
Assert.assertEquals("LindenFacetResult(dim:Author, value:11, childCount:4, " + "labelValues:[LindenLabelAndValue(label:Lisa, value:4), " + "LindenLabelAndValue(label:Susan, value:4), " + "LindenLabelAndValue(label:Bob, value:2), " + "LindenLabelAndValue(label:Frank, value:1)])", result.getFacetResults().get(0).toString());
// PublishDate facet
Assert.assertEquals("LindenFacetResult(dim:PublishDate, value:11, childCount:4, " + "labelValues:[LindenLabelAndValue(label:2010, value:4), " + "LindenLabelAndValue(label:2012, value:3), " + "LindenLabelAndValue(label:1999, value:3), " + "LindenLabelAndValue(label:2013, value:1)])", result.getFacetResults().get(1).toString());
// Top 2 PublishDate facet
Assert.assertEquals("LindenFacetResult(dim:PublishDate, value:11, childCount:4, " + "labelValues:[LindenLabelAndValue(label:2010, value:4), " + "LindenLabelAndValue(label:2012, value:3)])", result.getFacetResults().get(2).toString());
// PublishDate facet under path 2010
Assert.assertEquals("LindenFacetResult(dim:PublishDate, path:2010, value:4, childCount:2, " + "labelValues:[LindenLabelAndValue(label:10, value:3), " + "LindenLabelAndValue(label:11, value:1)])", result.getFacetResults().get(3).toString());
// PublishDate facet under path 2010,10
Assert.assertEquals("LindenFacetResult(dim:PublishDate, path:2010/10, value:3, childCount:3, " + "labelValues:[LindenLabelAndValue(label:15, value:1), " + "LindenLabelAndValue(label:20, value:1), " + "LindenLabelAndValue(label:25, value:1)])", result.getFacetResults().get(4).toString());
// PublishDate facet under path 2010,10,15
Assert.assertEquals("LindenFacetResult(dim:PublishDate, path:2010/10/15, value:0, childCount:0)", result.getFacetResults().get(5).toString());
// Non-existent-path
Assert.assertEquals("LindenFacetResult(dim:PublishDate, path:2010/13, value:0, childCount:0)", result.getFacetResults().get(6).toString());
// Non-existent-path
Assert.assertEquals("LindenFacetResult(dim:Author, path:non-existent-path, value:0, childCount:0)", result.getFacetResults().get(7).toString());
}
use of com.xiaomi.linden.thrift.common.LindenResult in project linden by XiaoMi.
the class TestLindenFacet method facetTest5.
// Drill sideways
@Test
public void facetTest5() 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 sideways PublishDate('2010')";
request = bqlCompiler.compile(bql).getSearchRequest();
result = lindenCore.search(request);
Assert.assertEquals(4, result.getTotalHits());
Assert.assertEquals(2, result.getFacetResultsSize());
// Author facet under PublishDate 2010
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 is not effected by drill down Path
Assert.assertEquals("LindenFacetResult(dim:PublishDate, value:11, childCount:4, " + "labelValues:[LindenLabelAndValue(label:2010, value:4), LindenLabelAndValue(label:2012, value:3), " + "LindenLabelAndValue(label:1999, value:3), LindenLabelAndValue(label:2013, value:1)])", result.getFacetResults().get(1).toString());
}
use of com.xiaomi.linden.thrift.common.LindenResult in project linden by XiaoMi.
the class TestLindenFacet method facetTest8.
// test facet source
@Test
public void facetTest8() throws Exception {
String bql = "select * from Linden browse by Author, PublishDate source";
LindenSearchRequest request = bqlCompiler.compile(bql).getSearchRequest();
LindenResult result = lindenCore.search(request);
Assert.assertEquals(13, result.getTotalHits());
Assert.assertEquals(2, result.getFacetResultsSize());
Assert.assertEquals("LindenHit(id:1, score:1.0, source:{\"PublishDate\":\"2010/10/15\",\"Language\":\"cn\",\"Author\":\"Bob\",\"id\":\"1\"})", result.getHits().get(0).toString());
bql = "select Author from Linden browse by Author, PublishDate source";
request = bqlCompiler.compile(bql).getSearchRequest();
result = lindenCore.search(request);
Assert.assertEquals(result.getHits().get(0).toString(), "LindenHit(id:1, score:1.0, source:{\"Author\":\"Bob\",\"id\":\"1\"})");
}
Aggregations