Skip to content

Commit

Permalink
Support ID query paging (#6737)
Browse files Browse the repository at this point in the history
  • Loading branch information
derekwilhelm authored May 19, 2023
1 parent 3f58bf3 commit 0466b54
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import ddf.catalog.data.impl.ResultImpl;
import ddf.catalog.filter.FilterAdapter;
import ddf.catalog.operation.FacetAttributeResult;
import ddf.catalog.operation.Query;
import ddf.catalog.operation.QueryRequest;
import ddf.catalog.operation.SourceResponse;
import ddf.catalog.operation.TermFacetProperties;
Expand Down Expand Up @@ -196,13 +197,9 @@ public SourceResponse query(QueryRequest request) throws UnsupportedQueryExcepti

try {
QueryResponse solrResponse;
boolean doRealTimeGet =
(boolean) request.getProperties().getOrDefault(DO_REALTIME_GET, false)
|| BooleanUtils.toBoolean(
filterAdapter.adapt(request.getQuery(), new RealTimeGetDelegate()));

LOGGER.trace("Begin executing solr query: query request {}", request);
if (doRealTimeGet) {
if (shouldDoRealTimeGet(request)) {
LOGGER.debug("Performing real time query");
SolrQuery realTimeQuery = getRealTimeQuery(query, solrFilterDelegate.getIds());
solrResponse = client.query(realTimeQuery, METHOD.POST);
Expand Down Expand Up @@ -237,6 +234,18 @@ public SourceResponse query(QueryRequest request) throws UnsupportedQueryExcepti
return new SourceResponseImpl(request, responseProps, results, totalHits);
}

private boolean shouldDoRealTimeGet(QueryRequest request) throws UnsupportedQueryException {
Query query = request.getQuery();
if (query.getStartIndex() > 1) {
// solr doesn't support paging of real time get requests so if a paging request is received
// here, it is safe to assume that we should not be doing a real time get to solr
return false;
}

return (boolean) request.getProperties().getOrDefault(DO_REALTIME_GET, false)
|| BooleanUtils.toBoolean(filterAdapter.adapt(query, new RealTimeGetDelegate()));
}

private List<SolrDocument> getSolrDocs(Set<String> ids) throws UnsupportedQueryException {
List<SolrDocument> solrDocs = new ArrayList<>(ids.size());
List<List<String>> partitions = Lists.partition(new ArrayList<>(ids), GET_BY_ID_LIMIT);
Expand Down

0 comments on commit 0466b54

Please sign in to comment.