Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.26.x] Support ID query paging #6737

Merged
merged 1 commit into from
May 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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