Source:
public List<DocumentModel> getCurrentPage() { long t0 = System.currentTimeMillis(); if (currentPageDocuments != null) { return currentPageDocuments; } error = null; errorMessage = null; log.debug("Perform query for provider '%s': with pageSize=%d, offset=%d", this::getName, this::getMinMaxPageSize, this::getCurrentPageOffset); currentPageDocuments = new ArrayList<>(); CoreSession coreSession = getCoreSession(); if (query == null) { buildQuery(coreSession); } if (query == null) { throw new NuxeoException(String.format("Cannot perform null query: check provider '%s'", getName())); } ElasticSearchService ess = Framework.getService(ElasticSearchService.class); try { NxQueryBuilder nxQuery = new NxQueryBuilder(getCoreSession()).nxql(query) .offset((int) getCurrentPageOffset()) .limit(getLimit()) .addAggregates(buildAggregates()); if (searchOnAllRepositories()) { nxQuery.searchOnAllRepositories(); } List<String> highlightFields = getHighlights(); if (highlightFields != null && !highlightFields.isEmpty()) { nxQuery.highlight(highlightFields); } EsResult ret = ess.queryAndAggregate(nxQuery); DocumentModelList dmList = ret.getDocuments(); currentAggregates = new HashMap<>(ret.getAggregates().size()); for (Aggregate<Bucket> agg : ret.getAggregates()) { currentAggregates.put(agg.getId(), agg); } setResultsCount(dmList.totalSize()); currentPageDocuments = dmList; } catch (QueryParseException e) { error = e; errorMessage = e.getMessage(); log.warn(e.getMessage(), e); } fireSearchEvent(getCoreSession().getPrincipal(), query, currentPageDocuments, System.currentTimeMillis() - t0); return currentPageDocuments; }

Target:
public List<DocumentModel> getCurrentPage() { long t0 = System.currentTimeMillis(); if (currentPageDocuments != null) { return currentPageDocuments; } error = null; errorMessage = null; log.debug("Perform query for provider '{}': with pageSize={}, offset={}", this::getName, this::getMinMaxPageSize, this::getCurrentPageOffset); currentPageDocuments = new ArrayList<>(); CoreSession coreSession = getCoreSession(); if (query == null) { buildQuery(coreSession); } if (query == null) { throw new NuxeoException(String.format("Cannot perform null query: check provider '%s'", getName())); } ElasticSearchService ess = Framework.getService(ElasticSearchService.class); try { NxQueryBuilder nxQuery = new NxQueryBuilder(getCoreSession()).nxql(query) .offset((int) getCurrentPageOffset()) .limit(getLimit()) .addAggregates(buildAggregates()); if (searchOnAllRepositories()) { nxQuery.searchOnAllRepositories(); } List<String> highlightFields = getHighlights(); if (highlightFields != null && !highlightFields.isEmpty()) { nxQuery.highlight(highlightFields); } EsResult ret = ess.queryAndAggregate(nxQuery); DocumentModelList dmList = ret.getDocuments(); currentAggregates = new HashMap<>(ret.getAggregates().size()); for (Aggregate<Bucket> agg : ret.getAggregates()) { currentAggregates.put(agg.getId(), agg); } setResultsCount(dmList.totalSize()); currentPageDocuments = dmList; } catch (QueryParseException e) { error = e; errorMessage = e.getMessage(); log.warn(e.getMessage(), e); } fireSearchEvent(getCoreSession().getPrincipal(), query, currentPageDocuments, System.currentTimeMillis() - t0); return currentPageDocuments; }