0

I am using Spring Data Elastic Search for querying from elastic search DB.

I need to highlight and display the searched text in the search results.

I have my setting like below

    SearchQuery searchQuery = new NativeSearchQueryBuilder()
        .matchQuery("title", "Damaged"))
        .withHighlightFields(new HighlightBuilder.Field("Damaged").preTags("<em>").postTags("</em>").fragmentSize(250))
        .build();

FacetedPage<Result> results = myRepository.search(searchQuery); 

But the data that is returned as search results is not highlighted .

Sayed Abolfazl Fatemi
  • 3,678
  • 3
  • 36
  • 48
lives
  • 1,243
  • 5
  • 25
  • 61
  • Possible duplicate of [How to provide highlighting with Spring data elasticsearch](https://stackoverflow.com/questions/37049764/how-to-provide-highlighting-with-spring-data-elasticsearch) – Tony Jul 13 '17 at 05:38

1 Answers1

1

Refer the below link - It works

How to provide highlighting with Spring data elasticsearch

Community
  • 1
  • 1
lives
  • 1,243
  • 5
  • 25
  • 61