Example usage for org.springframework.data.solr.core.query.result HighlightPage getHighlighted

List of usage examples for org.springframework.data.solr.core.query.result HighlightPage getHighlighted

Introduction

In this page you can find the example usage for org.springframework.data.solr.core.query.result HighlightPage getHighlighted.

Prototype

List<HighlightEntry<T>> getHighlighted();

Source Link

Usage

From source file:example.springdata.solr.AdvancedSolrRepositoryTests.java

/**
 * {@link HighlightPage} holds next to the entities found also information about where a match was found within the
 * document. This allows to fine grained display snipplets of data containing the matching term in context.
 *///from w w  w  .jav  a2 s  .c  o  m
@Test
public void annotationBasedHighlighting() {

    HighlightPage<Product> products = repository.findByDescriptionStartingWith("play", new PageRequest(0, 10));

    products.getHighlighted().forEach(entry -> entry.getHighlights().forEach(highligh -> System.out.println(
            entry.getEntity().getId() + " | " + highligh.getField() + ":\t" + highligh.getSnipplets())));
}