use of com.yelp.nrtsearch.server.grpc.FacetResult in project nrtsearch by Yelp.
the class DocValuesFacetsTest method assertResponse.
private void assertResponse(SearchResponse response, double value, int childCount, int valuesCount, ExpectedValues... expectedValues) {
assertEquals(1, response.getFacetResultCount());
FacetResult result = response.getFacetResult(0);
assertEquals("doc_values_facet", result.getName());
assertTrue(response.getDiagnostics().containsFacetTimeMs("doc_values_facet"));
assertEquals(value, result.getValue(), 0);
assertEquals(childCount, result.getChildCount());
assertEquals(valuesCount, result.getLabelValuesCount());
int sum = 0;
for (ExpectedValues v : expectedValues) {
sum += v.labels.size();
}
assertEquals(sum, valuesCount);
int valuesIndex = 0;
for (ExpectedValues v : expectedValues) {
Set<String> valueSet = new HashSet<>();
for (int i = 0; i < v.labels.size(); ++i) {
valueSet.add(result.getLabelValues(valuesIndex).getLabel());
assertEquals(v.count, result.getLabelValues(valuesIndex).getValue(), 0);
valuesIndex++;
}
assertEquals(v.labels, valueSet);
}
}
use of com.yelp.nrtsearch.server.grpc.FacetResult in project nrtsearch by Yelp.
the class TextFieldFacetsTest method testHierarchyWithPath.
@Test
public void testHierarchyWithPath() {
SearchResponse response = getSearchResponse("hierarchy_facet_field", "home");
List<FacetResult> facetResults = response.getFacetResultList();
List<LabelAndValue> expectedLabelAndValues = new ArrayList<>();
expectedLabelAndValues.add(LabelAndValue.newBuilder().setLabel("mike").setValue(1.0).build());
expectedLabelAndValues.add(LabelAndValue.newBuilder().setLabel("john").setValue(1.0).build());
// NOTE: total number of buckets/value returned by FastTaxonomyFacetCounts is -1 on multivalued
// fields.
assertFacetResult(facetResults.get(0), "hierarchy_facet_field", -1, 2L, expectedLabelAndValues, "home");
response = getSearchResponse("hierarchy_facet_field", "home", "john");
facetResults = response.getFacetResultList();
expectedLabelAndValues = new ArrayList<>();
expectedLabelAndValues.add(LabelAndValue.newBuilder().setLabel("work").setValue(1.0).build());
expectedLabelAndValues.add(LabelAndValue.newBuilder().setLabel("personal").setValue(1.0).build());
// NOTE: total number of buckets/value returned by FastTaxonomyFacetCounts is -1 on multivalued
// fields.
assertFacetResult(facetResults.get(0), "hierarchy_facet_field", -1, 2L, expectedLabelAndValues, "home", "john");
}
Aggregations