Search in sources :

Example 1 with HighlightEntry

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;
}
Also used : ArrayList(java.util.ArrayList) IProduct(com.nixmash.blog.solr.model.IProduct) Product(com.nixmash.blog.solr.model.Product) HighlightEntry(org.springframework.data.solr.core.query.result.HighlightEntry)

Aggregations

IProduct (com.nixmash.blog.solr.model.IProduct)1 Product (com.nixmash.blog.solr.model.Product)1 ArrayList (java.util.ArrayList)1 HighlightEntry (org.springframework.data.solr.core.query.result.HighlightEntry)1