Search in sources :

Example 1 with Facet

use of com.yelp.nrtsearch.server.grpc.Facet in project nrtsearch by Yelp.

the class FacetScriptFacetsTest method testNullValue.

@Test
public void testNullValue() {
    Facet facet = Facet.newBuilder().setScript(Script.newBuilder().setLang("test_lang").setSource("null").build()).setTopN(10).build();
    SearchResponse response = doQuery(facet);
    assertEquals(1, response.getFacetResultCount());
    FacetResult result = response.getFacetResult(0);
    assertEquals(100, result.getValue(), 0);
    assertEquals(0, result.getChildCount());
    assertEquals(0, result.getLabelValuesCount());
}
Also used : FacetResult(com.yelp.nrtsearch.server.grpc.FacetResult) Facet(com.yelp.nrtsearch.server.grpc.Facet) SearchResponse(com.yelp.nrtsearch.server.grpc.SearchResponse) Test(org.junit.Test)

Example 2 with Facet

use of com.yelp.nrtsearch.server.grpc.Facet in project nrtsearch by Yelp.

the class FacetScriptFacetsTest method testFacetLabelSubset.

@Test
public void testFacetLabelSubset() {
    Facet facet = Facet.newBuilder().setScript(Script.newBuilder().setLang("test_lang").setSource("concat").build()).setTopN(4).build();
    SearchResponse response = doQuery(facet);
    assertResponse(response, 100, 6, 4, new ExpectedValues(new HashSet<>(Arrays.asList("0_0", "0_1", "1_1", "2_0")), 17));
}
Also used : Facet(com.yelp.nrtsearch.server.grpc.Facet) SearchResponse(com.yelp.nrtsearch.server.grpc.SearchResponse) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with Facet

use of com.yelp.nrtsearch.server.grpc.Facet in project nrtsearch by Yelp.

the class FacetScriptFacetsTest method testIterableRangeValue.

@Test
public void testIterableRangeValue() {
    Facet facet = Facet.newBuilder().setScript(Script.newBuilder().setLang("test_lang").setSource("combine").build()).setTopN(10).build();
    SearchResponse response = doRangeQuery(facet);
    assertResponse(response, 10, 3, 3, new ExpectedValues(new HashSet<>(Arrays.asList("0", "1")), 6), new ExpectedValues(new HashSet<>(Collections.singletonList("2")), 4));
}
Also used : Facet(com.yelp.nrtsearch.server.grpc.Facet) SearchResponse(com.yelp.nrtsearch.server.grpc.SearchResponse) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with Facet

use of com.yelp.nrtsearch.server.grpc.Facet in project nrtsearch by Yelp.

the class FacetScriptFacetsTest method testFacetGreaterN.

@Test
public void testFacetGreaterN() {
    Facet facet = Facet.newBuilder().setScript(Script.newBuilder().setLang("test_lang").setSource("concat").build()).setTopN(10).build();
    SearchResponse response = doQuery(facet);
    assertResponse(response, 100, 6, 6, new ExpectedValues(new HashSet<>(Arrays.asList("0_0", "0_1", "1_1", "2_0")), 17), new ExpectedValues(new HashSet<>(Arrays.asList("1_0", "2_1")), 16));
}
Also used : Facet(com.yelp.nrtsearch.server.grpc.Facet) SearchResponse(com.yelp.nrtsearch.server.grpc.SearchResponse) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 5 with Facet

use of com.yelp.nrtsearch.server.grpc.Facet in project nrtsearch by Yelp.

the class FacetScriptFacetsTest method testIterableLabelSubset.

@Test
public void testIterableLabelSubset() {
    Facet facet = Facet.newBuilder().setScript(Script.newBuilder().setLang("test_lang").setSource("combine").build()).setTopN(2).build();
    SearchResponse response = doQuery(facet);
    assertResponse(response, 100, 3, 2, new ExpectedValues(new HashSet<>(Collections.singletonList("0")), 67), new ExpectedValues(new HashSet<>(Collections.singletonList("1")), 66));
}
Also used : Facet(com.yelp.nrtsearch.server.grpc.Facet) SearchResponse(com.yelp.nrtsearch.server.grpc.SearchResponse) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

Facet (com.yelp.nrtsearch.server.grpc.Facet)43 Test (org.junit.Test)41 SearchResponse (com.yelp.nrtsearch.server.grpc.SearchResponse)29 HashSet (java.util.HashSet)28 FacetResult (com.yelp.nrtsearch.server.grpc.FacetResult)3 ArrayList (java.util.ArrayList)3 IndexState (com.yelp.nrtsearch.server.luceneserver.IndexState)2 HashMap (java.util.HashMap)2 NumericRangeType (com.yelp.nrtsearch.server.grpc.NumericRangeType)1 Diagnostics (com.yelp.nrtsearch.server.grpc.SearchResponse.Diagnostics)1 LoadedDocValues (com.yelp.nrtsearch.server.luceneserver.doc.LoadedDocValues)1 FieldDef (com.yelp.nrtsearch.server.luceneserver.field.FieldDef)1 IndexableFieldDef (com.yelp.nrtsearch.server.luceneserver.field.IndexableFieldDef)1 IOException (java.io.IOException)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Facets (org.apache.lucene.facet.Facets)1 FacetsCollector (org.apache.lucene.facet.FacetsCollector)1