【发布时间】:2018-04-12 07:40:07
【问题描述】:
我需要获取所有可分页的文档,但出现此错误
com.fasterxml.jackson.databind.JsonMappingException: (是 java.lang.NullPointerException) (通过引用链: org.springframework.data.elasticsearch.core.aggregation.impl.AggregatedPageImpl["facets"])
存储库
public interface ConventionSearchRepository extends ElasticsearchRepository<Convention, Long> {
}
服务
@Service
@Transactional
public class ConventionServiceImpl implements ConventionService {
private final ConventionSearchRepository conventionSearchRepository;
@Override
@Transactional(readOnly = true)
public Page<Convention> findAll(final PageRequest pageable) {
return conventionSearchRepository.findAll(pageable);
}
}
控制器
@GetMapping("/conventions")
public Page<Convention> getAllConventions(@RequestParam(value = "_page", required = false, defaultValue = "0") int page,
@RequestParam(value = "_perPage", required = false, defaultValue = "20") int perPage,
@RequestParam(value = "_sortDir", required = false, defaultValue = "DESC") Sort.Direction sortDir,
@RequestParam(value = "_sortBy", required = false, defaultValue = "shortname") String sortBy) {
Sort sort = new Sort(sortDir, sortBy);
PageRequest pageRequest = new PageRequest(page, perPage, sort);
return conventionService.findAll(pageRequest);
}
【问题讨论】:
标签: elasticsearch spring-data-elasticsearch