use of org.springframework.data.solr.core.query.result.HighlightEntry in project nixmash-blog by mintster.
the class SolrUtils method highlightPagesToList.
public static List<Product> highlightPagesToList(HighlightPage<Product> productPage) {
List<Product> products = new ArrayList<Product>();
for (HighlightEntry<Product> highlightedProduct : productPage.getHighlighted()) {
Product product = new Product(highlightedProduct.getEntity().getId(), highlightedProduct.getEntity().getName());
products.add(product);
for (HighlightEntry.Highlight highlight : highlightedProduct.getHighlights()) {
for (String snippet : highlight.getSnipplets()) {
if (highlight.getField().getName().equals(IProduct.NAME_FIELD)) {
product.setName(snippet);
}
}
}
}
return products;
}
Aggregations