diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImpl.java index 2e43c0fdaef..1552acfbb51 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImpl.java @@ -40,6 +40,7 @@ import ca.uhn.fhir.model.api.Include; import ca.uhn.fhir.rest.api.CacheControlDirective; import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.SearchTotalModeEnum; +import ca.uhn.fhir.rest.api.SummaryEnum; import ca.uhn.fhir.rest.api.server.IBundleProvider; import ca.uhn.fhir.rest.api.server.IPreResourceAccessDetails; import ca.uhn.fhir.rest.api.server.RequestDetails; @@ -962,8 +963,12 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc { * * before doing anything else. */ - boolean wantOnlyCount = myParams.wantOnlyCount(myDaoConfig.getDefaultTotalMode()); - if (wantOnlyCount) { + boolean wantOnlyCount = SummaryEnum.COUNT.equals(myParams.getSummaryMode()); + boolean wantCount = + wantOnlyCount || + SearchTotalModeEnum.ACCURATE.equals(myParams.getSearchTotalMode()) || + (myParams.getSearchTotalMode() == null && SearchTotalModeEnum.ACCURATE.equals(myDaoConfig.getDefaultTotalMode())); + if (wantCount) { ourLog.trace("Performing count"); ISearchBuilder sb = newSearchBuilder(); Iterator countIterator = sb.createCountQuery(myParams, mySearch.getUuid(), myRequest); diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/SearchParameterMap.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/SearchParameterMap.java index 3c5e2281af8..4070f58af70 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/SearchParameterMap.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/SearchParameterMap.java @@ -495,12 +495,6 @@ public class SearchParameterMap implements Serializable { } } - public boolean wantOnlyCount(SearchTotalModeEnum theDefaultTotalMode) { - return SummaryEnum.COUNT.equals(mySummaryMode) || - SearchTotalModeEnum.ACCURATE.equals(mySearchTotalMode) || - (mySearchTotalMode == null && SearchTotalModeEnum.ACCURATE.equals(theDefaultTotalMode)); - } - public enum EverythingModeEnum { /* * Don't reorder! We rely on the ordinals