Example usage for org.springframework.data.solr.core.query HighlightOptions setSimplePostfix

List of usage examples for org.springframework.data.solr.core.query HighlightOptions setSimplePostfix

Introduction

In this page you can find the example usage for org.springframework.data.solr.core.query HighlightOptions setSimplePostfix.

Prototype

public HighlightOptions setSimplePostfix(String postfix) 

Source Link

Document

set hl.simple.post

Usage

From source file:com.nixmash.springdata.solr.repository.custom.CustomProductRepositoryImpl.java

@Override
public HighlightPage<Product> searchProductsWithHighlights(String searchTerm) {
    SimpleHighlightQuery query = new SimpleHighlightQuery();
    String[] words = searchTerm.split(" ");
    Criteria conditions = createHighlightedNameConditions(words);
    query.addCriteria(conditions);// ww w. j  a v  a 2  s .c  om

    HighlightOptions hlOptions = new HighlightOptions();
    hlOptions.addField("name");
    hlOptions.setSimplePrefix("<b>");
    hlOptions.setSimplePostfix("</b>");
    query.setHighlightOptions(hlOptions);

    return solrTemplate.queryForHighlightPage(query, Product.class);
}