fixing counts

This commit is contained in:
leif stawnyczy 2024-11-22 16:54:31 -05:00
parent dcf0c7158b
commit 18635f727e
2 changed files with 7 additions and 2 deletions

View File

@ -130,6 +130,7 @@ public class SynchronousSearchSvcImpl implements ISynchronousSearchSvc {
List<List<IQueryParameterType>> contentAndTerms = theParams.get(Constants.PARAM_CONTENT); List<List<IQueryParameterType>> contentAndTerms = theParams.get(Constants.PARAM_CONTENT);
List<List<IQueryParameterType>> textAndTerms = theParams.get(Constants.PARAM_TEXT); List<List<IQueryParameterType>> textAndTerms = theParams.get(Constants.PARAM_TEXT);
// TODO - this count query should not be grouped
count = theSb.createCountQuery( count = theSb.createCountQuery(
theParams, theSearchUuid, theRequestDetails, theRequestPartitionId); theParams, theSearchUuid, theRequestDetails, theRequestPartitionId);

View File

@ -762,7 +762,7 @@ public class SearchBuilder implements ISearchBuilder<JpaPid> {
* if the MaxResultsToFetch is null, we are requesting "everything", * if the MaxResultsToFetch is null, we are requesting "everything",
* so we'll let the db do the deduplication (instead of in-memory) * so we'll let the db do the deduplication (instead of in-memory)
*/ */
if (theOffset != null || myMaxResultsToFetch == null) { if (theOffset != null || (myMaxResultsToFetch == null && !theCountOnlyFlag)) {
queryStack3.addGrouping(); queryStack3.addGrouping();
queryStack3.setUseAggregate(true); queryStack3.setUseAggregate(true);
} }
@ -2507,7 +2507,11 @@ public class SearchBuilder implements ISearchBuilder<JpaPid> {
} }
} }
mySearchRuntimeDetails.setFoundMatchesCount(myPidSet.size()); if (myMaxResultsToFetch == null) {
mySearchRuntimeDetails.setFoundIndexMatchesCount(myNonSkipCount);
} else {
mySearchRuntimeDetails.setFoundMatchesCount(myPidSet.size());
}
} finally { } finally {
// search finished - fire hooks // search finished - fire hooks