Skip to content

Commit

Permalink
Backport for 7.4.5 (#6383)
Browse files Browse the repository at this point in the history
* backport - fixing bug with fulltext and jpa search filters (#6374)

* 2024.08.R05 backport - version bump

---------

Co-authored-by: TipzCM <[email protected]>
  • Loading branch information
volodymyr-korzh and TipzCM authored Oct 21, 2024
1 parent 64583e1 commit 43a4bd4
Show file tree
Hide file tree
Showing 87 changed files with 206 additions and 115 deletions.
2 changes: 1 addition & 1 deletion hapi-deployable-pom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>7.4.5-SNAPSHOT</version>
<version>7.4.5</version>

<relativePath>../pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-android/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>7.4.5-SNAPSHOT</version>
<version>7.4.5</version>

<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>7.4.5-SNAPSHOT</version>
<version>7.4.5</version>

<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,4 @@ public static Stream<Arguments> testIteratorChunkArguments() {
Arguments.of(List.of(1,2,3,4,5,6,7,8,9), List.of(List.of(1,2,3), List.of(4,5,6), List.of(7,8,9)))
);
}

}
4 changes: 2 additions & 2 deletions hapi-fhir-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-bom</artifactId>
<version>7.4.5-SNAPSHOT</version>
<version>7.4.5</version>

<packaging>pom</packaging>
<name>HAPI FHIR BOM</name>

<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>7.4.5-SNAPSHOT</version>
<version>7.4.5</version>

<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-checkstyle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>7.4.5-SNAPSHOT</version>
<version>7.4.5</version>

<relativePath>../pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-cli/hapi-fhir-cli-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>7.4.5-SNAPSHOT</version>
<version>7.4.5</version>

<relativePath>../../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-cli/hapi-fhir-cli-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-cli</artifactId>
<version>7.4.5-SNAPSHOT</version>
<version>7.4.5</version>

<relativePath>../pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>7.4.5-SNAPSHOT</version>
<version>7.4.5</version>

<relativePath>../pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-client-okhttp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>7.4.5-SNAPSHOT</version>
<version>7.4.5</version>

<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>7.4.5-SNAPSHOT</version>
<version>7.4.5</version>

<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-converter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>7.4.5-SNAPSHOT</version>
<version>7.4.5</version>

<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>7.4.5-SNAPSHOT</version>
<version>7.4.5</version>

<relativePath>../pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>7.4.5-SNAPSHOT</version>
<version>7.4.5</version>

<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
release-date: "2024-10-21"
codename: "Copernicus"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
type: fix
issue: 6372
jira: SMILE-9073
backport: 7.4.5
title: "Searches that combined full-text searching (i.e. `_text` or `_content`)
with other search parameters could fail to return all results if we encountered
1600 matches against the full-text index where none of them match the rest of the query.
This has now been fixed.
"
2 changes: 1 addition & 1 deletion hapi-fhir-jacoco/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>7.4.5-SNAPSHOT</version>
<version>7.4.5</version>

<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-jaxrsserver-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>7.4.5-SNAPSHOT</version>
<version>7.4.5</version>

<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>7.4.5-SNAPSHOT</version>
<version>7.4.5</version>

<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-jpaserver-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>7.4.5-SNAPSHOT</version>
<version>7.4.5</version>

<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public class SynchronousSearchSvcImpl implements ISynchronousSearchSvc {
private int mySyncSize = 250;

@Override
@SuppressWarnings({"rawtypes", "unchecked"})
public IBundleProvider executeQuery(
SearchParameterMap theParams,
RequestDetails theRequestDetails,
Expand All @@ -113,7 +114,6 @@ public IBundleProvider executeQuery(
.withRequestPartitionId(theRequestPartitionId)
.readOnly()
.execute(() -> {

// Load the results synchronously
List<JpaPid> pids = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ public class SearchBuilder implements ISearchBuilder<JpaPid> {
@Deprecated
public static final int MAXIMUM_PAGE_SIZE = SearchConstants.MAX_PAGE_SIZE;

public static final int MAXIMUM_PAGE_SIZE_FOR_TESTING = 50;
public static final String RESOURCE_ID_ALIAS = "resource_id";
public static final String RESOURCE_VERSION_ALIAS = "resource_version";
private static final Logger ourLog = LoggerFactory.getLogger(SearchBuilder.class);
Expand All @@ -171,7 +170,7 @@ public class SearchBuilder implements ISearchBuilder<JpaPid> {
private static final String MY_TARGET_RESOURCE_TYPE = "myTargetResourceType";
private static final String MY_SOURCE_RESOURCE_TYPE = "mySourceResourceType";
private static final String MY_TARGET_RESOURCE_VERSION = "myTargetResourceVersion";
public static boolean myUseMaxPageSize50ForTest = false;
public static Integer myMaxPageSizeForTests = null;
protected final IInterceptorBroadcaster myInterceptorBroadcaster;
protected final IResourceTagDao myResourceTagDao;
private String myResourceName;
Expand Down Expand Up @@ -464,6 +463,8 @@ private List<ISearchQueryExecutor> createQuery(
.chunk(
fulltextExecutor,
SearchBuilder.getMaximumPageSize(),
// for each list of (SearchBuilder.getMaximumPageSize())
// we create a chunked query and add it to 'queries'
t -> doCreateChunkedQueries(
theParams, t, theOffset, sort, theCountOnlyFlag, theRequest, queries));
}
Expand Down Expand Up @@ -2343,15 +2344,23 @@ private void fetchNext() {
if (myNext == null) {
// no next means we need a new query (if one is available)
while (myResultsIterator.hasNext() || !myQueryList.isEmpty()) {
// Update iterator with next chunk if necessary.
if (!myResultsIterator.hasNext()) {
/*
* Because we combine our DB searches with Lucene
* sometimes we can have multiple results iterators
* (with only some having data in them to extract).
*
* We'll iterate our results iterators until we
* either run out of results iterators, or we
* have one that actually has data in it.
*/
while (!myResultsIterator.hasNext() && !myQueryList.isEmpty()) {
retrieveNextIteratorQuery();
}

// if our new results iterator is also empty
if (!myResultsIterator.hasNext()) {
// we couldn't find a results iterator;
// we're done here
if (!myResultsIterator.hasNext()) {
break;
}
break;
}

Long nextLong = myResultsIterator.next();
Expand Down Expand Up @@ -2571,14 +2580,13 @@ private void firePerformanceMessage(RequestDetails theRequest, String theMessage
}

public static int getMaximumPageSize() {
if (myUseMaxPageSize50ForTest) {
return MAXIMUM_PAGE_SIZE_FOR_TESTING;
} else {
return MAXIMUM_PAGE_SIZE;
if (myMaxPageSizeForTests != null) {
return myMaxPageSizeForTests;
}
return MAXIMUM_PAGE_SIZE;
}

public static void setMaxPageSize50ForTest(boolean theIsTest) {
myUseMaxPageSize50ForTest = theIsTest;
public static void setMaxPageSizeForTest(Integer theTestSize) {
myMaxPageSizeForTests = theTestSize;
}
}
2 changes: 1 addition & 1 deletion hapi-fhir-jpaserver-elastic-test-utilities/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>7.4.5-SNAPSHOT</version>
<version>7.4.5</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,19 @@ public void before() throws Exception {
mySmallerPreFetchThresholds.add(-1);
myStorageSettings.setSearchPreFetchThresholds(mySmallerPreFetchThresholds);

SearchBuilder.setMaxPageSize50ForTest(true);
SearchBuilder.setMaxPageSizeForTest(50);

myStorageSettings.setLastNEnabled(true);

}

@AfterEach
public void after() {
myStorageSettings.setSearchPreFetchThresholds(originalPreFetchThresholds);
SearchBuilder.setMaxPageSize50ForTest(false);
SearchBuilder.setMaxPageSizeForTest(null);
}

@Test
public void testLastNChunking() {

runInTransaction(() -> {
Set<Long> all = mySearchDao.findAll().stream().map(Search::getId).collect(Collectors.toSet());

Expand All @@ -103,9 +101,6 @@ public void testLastNChunking() {
Map<String, String[]> requestParameters = new HashMap<>();
when(mySrd.getParameters()).thenReturn(requestParameters);

// Set chunk size to 50
SearchBuilder.setMaxPageSize50ForTest(true);

// Expand default fetch sizes to ensure all observations are returned in first page:
List<Integer> myBiggerPreFetchThresholds = new ArrayList<>();
myBiggerPreFetchThresholds.add(100);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void enableAdvancedHSearchIndexing() {

@AfterEach
public void reset() {
SearchBuilder.setMaxPageSize50ForTest(false);
SearchBuilder.setMaxPageSizeForTest(null);
myStorageSettings.setStoreResourceInHSearchIndex(new JpaStorageSettings().isStoreResourceInHSearchIndex());
myStorageSettings.setAdvancedHSearchIndexing(new JpaStorageSettings().isAdvancedHSearchIndexing());
}
Expand Down Expand Up @@ -77,7 +77,7 @@ public void testLastNChunking() {
when(mySrd.getParameters()).thenReturn(requestParameters);

// Set chunk size to 50
SearchBuilder.setMaxPageSize50ForTest(true);
SearchBuilder.setMaxPageSizeForTest(50);

myCaptureQueriesListener.clear();
List<String> results = toUnqualifiedVersionlessIdValues(myObservationDao.observationsLastN(params, mockSrd(), null));
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-jpaserver-hfql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>7.4.5-SNAPSHOT</version>
<version>7.4.5</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-jpaserver-ips/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>7.4.5-SNAPSHOT</version>
<version>7.4.5</version>

<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-jpaserver-mdm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>7.4.5-SNAPSHOT</version>
<version>7.4.5</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-jpaserver-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>7.4.5-SNAPSHOT</version>
<version>7.4.5</version>

<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-jpaserver-searchparam/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>7.4.5-SNAPSHOT</version>
<version>7.4.5</version>

<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-jpaserver-subscription/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>7.4.5-SNAPSHOT</version>
<version>7.4.5</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion hapi-fhir-jpaserver-test-dstu2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>7.4.5-SNAPSHOT</version>
<version>7.4.5</version>

<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
Expand Down
Loading

0 comments on commit 43a4bd4

Please sign in to comment.