I am trying to query a mongoDB collection sorting by an array value(in addition to other fields) and the results need to be paginated also. The sorting is not working for the array value, but it works for other fields. Here is the code:
sortBy = "programInstance.title.descriptions[0].value";
PageRequest pageRequest = = PageRequest.of(filter.getPageNumber(), filter.getPageSize(),
new Sort("DESC".equalsIgnoreCase(filter.getSortOrder()) ? Sort.Direction.DESC : Sort.Direction.ASC, sortBy));
Page<Offer> st = new PageImpl<>(mongoTemplate.find(query.with(pageRequest),Offer.class), pageRequest, pageCount);
Any help is very much appreciated..