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

Support ID query paging #6742

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,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 @@ -193,12 +194,8 @@ 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()));

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 @@ -232,6 +229,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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ I wonder if we should put something into the query response properties to indicate we ignored the real time get request? Or maybe add a debug log instead of this comment to help someone debugging a request?

// 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