I have the following REST controller.
@RepositoryRestController
@RequestMapping(value = \"/booksCustom\")
public class BooksController extends ResourceSupport {
I was using Page
instead of HighlightPage
to create the response page. Page obviously doesn't contain content
which was causing the highlighted portion to be truncated. I ended up creating a new page based off of HighlightPage and returning that as my result instead of Page.
@RepositoryRestController
@RequestMapping(value = "/booksCustom")
public class BooksController extends ResourceSupport {
@Autowired
public BooksService booksService;
@Autowired
private PagedResourcesAssembler booksAssembler;
@RequestMapping("/search")
public HttpEntity>> search(@RequestParam(value = "q", required = false) String query, @PageableDefault(page = 0, size = 20) Pageable pageable) {
HighlightPage solrBookResult = booksService.findBookText(query, pageable);
Page highlightedPages = new PageImpl(solrBookResult.getHighlighted(), pageable, solrBookResult.getTotalElements());
return new ResponseEntity>>(booksAssembler.toResource(highlightedPages), HttpStatus.OK);
}
Probably a better way of doing this, but I couldn't find anything that would do what I wanted it to do without having a change a ton of code. Hope this helps!