*
* @param searchResult the search results with digests.
* @return SearchResponse
*/
public static SearchResponse serializeSearchResult(SearchResult searchResult, int total) {
Builder searchBuilder = SearchResponse.newBuilder();
searchBuilder.setQuery(searchResult.getQuery()).setTotalResults(total);
for (SearchResult.Digest searchResultDigest : searchResult.getDigests()) {
SearchResponse.Digest digest = serializeDigest(searchResultDigest);
searchBuilder.addDigests(digest);
}
SearchResponse searchResponse = searchBuilder.build();
return searchResponse;
}