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 .
Refer the below link - It works