Respect the _total parameter for all JPA searches

This commit is contained in:
James Agnew 2019-06-09 05:44:49 -04:00
parent b72f1c4555
commit c2aec5c1a9
4 changed files with 50 additions and 1 deletions

View File

@ -214,6 +214,41 @@ public class FhirResourceDaoR4SearchOptimizedTest extends BaseJpaR4Test {
}
@Test
public void testCountEvenIfPreviousSimilarSearchDidNotRequestIt() {
create200Patients();
myDaoConfig.setSearchPreFetchThresholds(Arrays.asList(20, 50, 190));
SearchParameterMap params = new SearchParameterMap();
params.setSort(new SortSpec(Patient.SP_NAME));
IBundleProvider results = myPatientDao.search(params);
String uuid = results.getUuid();
ourLog.info("** Search returned UUID: {}", uuid);
assertEquals(null, results.size());
List<String> ids = toUnqualifiedVersionlessIdValues(results, 0, 10, true);
assertEquals("Patient/PT00000", ids.get(0));
assertEquals("Patient/PT00009", ids.get(9));
assertEquals(null, myDatabaseBackedPagingProvider.retrieveResultList(uuid).size());
// Try the same query again. This time we'll request _total=accurate as well
// which means the total should be calculated no matter what.
params = new SearchParameterMap();
params.setSort(new SortSpec(Patient.SP_NAME));
params.setSearchTotalMode(SearchTotalModeEnum.ACCURATE);
results = myPatientDao.search(params);
String uuid2 = results.getUuid();
ourLog.info("** Search returned UUID: {}", uuid2);
assertEquals(200, results.size().intValue());
ids = toUnqualifiedVersionlessIdValues(results, 0, 10, true);
assertEquals("Patient/PT00000", ids.get(0));
assertEquals("Patient/PT00009", ids.get(9));
assertEquals(200, myDatabaseBackedPagingProvider.retrieveResultList(uuid2).size().intValue());
assertNotEquals(uuid, uuid2);
}
@Test
public void testFetchRightUpToActualNumberExistingThenFetchAnotherPage() {
create200Patients();

View File

@ -427,6 +427,13 @@ public class SearchParameterMap implements Serializable {
b.append(getSummaryMode().getCode());
}
if (getSearchTotalMode() != null) {
addUrlParamSeparator(b);
b.append(Constants.PARAM_SEARCH_TOTAL_MODE);
b.append('=');
b.append(getSearchTotalMode().getCode());
}
if (b.length() == 0) {
b.append('?');
}

View File

@ -1585,7 +1585,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.3</version>
<version>0.8.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -2299,6 +2299,7 @@
<module>hapi-fhir-cli</module>
<module>hapi-fhir-dist</module>
<module>examples</module>
<module>osgi</module>
<!--<module>osgi/hapi-fhir-karaf-features</module>
<module>osgi/hapi-fhir-karaf-integration-tests</module>-->
<module>example-projects/hapi-fhir-base-example-embedded-ws</module>

View File

@ -40,6 +40,12 @@
enforce referential integrity even if referential integrity was enabled. Thanks to
Tuomo Ala-Vannesluoma for reporting!
</action>
<action type="fix">
In the JPA server, the
<![CDATA[<code>_total=accurate</code>]]>
was not always respected if a previous search already existed
in the query cache that matched the same search parameters.
</action>
</release>
<release version="3.8.0" date="2019-05-30" description="Hippo">
<action type="fix">