use of com.yelp.nrtsearch.server.grpc.SearchResponse.Diagnostics in project nrtsearch by Yelp.
the class FacetTopDocs method facetTopDocsSample.
/**
* Compute facet aggregations based on a sample of the query's top ranked documents. Only
* processes facets that have sampleTopDocs set to a value greater than zero.
*
* @param topDocs top documents from query
* @param facets facet definition grpc messages
* @param indexState state for index
* @param searcher searcher for query
* @param diagnostics diagnostics builder for storing facet timing
* @return results for facets over top docs
* @throws IOException if error reading doc values
* @throws IllegalArgumentException if top docs facet field is not indexable or does not have doc
* values enabled
*/
public static Iterable<FacetResult> facetTopDocsSample(TopDocs topDocs, List<Facet> facets, IndexState indexState, IndexSearcher searcher, Diagnostics.Builder diagnostics) throws IOException {
List<Facet> sampleFacets = facets.stream().filter(facet -> facet.getSampleTopDocs() > 0).collect(Collectors.toList());
if (sampleFacets.isEmpty()) {
return Collections.emptyList();
}
List<FacetResult> facetResults = new ArrayList<>(sampleFacets.size());
for (Facet facet : sampleFacets) {
long startNS = System.nanoTime();
facetResults.add(facetFromTopDocs(topDocs, facet, indexState, searcher));
long endNS = System.nanoTime();
diagnostics.putFacetTimeMs(facet.getName(), (endNS - startNS) / 1000000.0);
}
return facetResults;
}
Aggregations