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

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

Introduction

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

Prototype

public HighlightOptions setSimplePrefix(String prefix) 

Source Link

Document

set hl.simple.pre

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);//from  w  w  w . j  a v  a 2  s.c o  m

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

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