From e29dc540e3092361ae28ec7d3c133c406e9cca93 Mon Sep 17 00:00:00 2001 From: Saurav Sharma Date: Sun, 8 Jun 2025 15:23:52 +0545 Subject: [PATCH 1/4] feat: add support to enable search index full text (#828) Signed-off-by: Saurav Sharma --- src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java | 9 +++++++++ .../fhir/jpa/starter/common/FhirServerConfigCommon.java | 1 + src/main/resources/application.yaml | 1 + src/main/resources/cds.application.yaml | 1 + .../ca/uhn/fhir/jpa/starter/ElasticsearchLastNR4IT.java | 1 + src/test/resources/application.yaml | 1 + 6 files changed, 14 insertions(+) diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java b/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java index 0095b53..05f90b9 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java @@ -34,6 +34,7 @@ public class AppProperties { private Boolean mdm_enabled = false; private String mdm_rules_json_location = "mdm-rules.json"; private boolean advanced_lucene_indexing = false; + private boolean search_index_full_text_enabled = false; private boolean enable_index_of_type = false; private Boolean allow_cascading_deletes = false; private Boolean allow_contains_searches = true; @@ -284,6 +285,14 @@ public class AppProperties { advanced_lucene_indexing = theAdvanced_lucene_indexing; } + public boolean getSearch_index_full_text_enabled() { + return this.search_index_full_text_enabled; + } + + public void setSearch_index_full_text_enabled(boolean theSearch_index_full_text_enabled) { + search_index_full_text_enabled = theSearch_index_full_text_enabled; + } + public Boolean getAllow_cascading_deletes() { return allow_cascading_deletes; } diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java b/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java index e9f3549..9c2007f 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java @@ -201,6 +201,7 @@ public class FhirServerConfigCommon { jpaStorageSettings.setFilterParameterEnabled(appProperties.getFilter_search_enabled()); jpaStorageSettings.setHibernateSearchIndexSearchParams(appProperties.getAdvanced_lucene_indexing()); + jpaStorageSettings.setHibernateSearchIndexFullText(appProperties.getSearch_index_full_text_enabled()); jpaStorageSettings.setTreatBaseUrlsAsLocal(new HashSet<>(appProperties.getLocal_base_urls())); jpaStorageSettings.setTreatReferencesAsLogical(new HashSet<>(appProperties.getLogical_urls())); diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index d4df357..849a6fa 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -200,6 +200,7 @@ hapi: ### !!Extended Lucene/Elasticsearch Indexing is still a experimental feature, expect some features (e.g. _total=accurate) to not work as expected!! ### more information here: https://hapifhir.io/hapi-fhir/docs/server_jpa/elastic.html advanced_lucene_indexing: false + search_index_full_text_enabled: false bulk_export_enabled: false bulk_import_enabled: false # language_search_parameter_enabled: true diff --git a/src/main/resources/cds.application.yaml b/src/main/resources/cds.application.yaml index 8a734ae..2d98309 100644 --- a/src/main/resources/cds.application.yaml +++ b/src/main/resources/cds.application.yaml @@ -196,6 +196,7 @@ hapi: ### !!Extended Lucene/Elasticsearch Indexing is still a experimental feature, expect some features (e.g. _total=accurate) to not work as expected!! ### more information here: https://hapifhir.io/hapi-fhir/docs/server_jpa/elastic.html advanced_lucene_indexing: false + search_index_full_text_enabled: false bulk_export_enabled: false bulk_import_enabled: false # language_search_parameter_enabled: true diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ElasticsearchLastNR4IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ElasticsearchLastNR4IT.java index b827946..26f6b9d 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ElasticsearchLastNR4IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ElasticsearchLastNR4IT.java @@ -52,6 +52,7 @@ import org.testcontainers.junit.jupiter.Testcontainers; "hapi.fhir.lastn_enabled=true", "hapi.fhir.store_resource_in_lucene_index_enabled=true", "hapi.fhir.advanced_lucene_indexing=true", + "hapi.fhir.search_index_full_text_enabled=true", "elasticsearch.enabled=true", "hapi.fhir.cr_enabled=false", diff --git a/src/test/resources/application.yaml b/src/test/resources/application.yaml index f57c1e2..cf70d28 100644 --- a/src/test/resources/application.yaml +++ b/src/test/resources/application.yaml @@ -129,6 +129,7 @@ hapi: ### !!Extended Lucene/Elasticsearch Indexing is still a experimental feature, expect some features (e.g. _total=accurate) to not work as expected!! ### more information here: https://hapifhir.io/hapi-fhir/docs/server_jpa/elastic.html advanced_lucene_indexing: false + search_index_full_text_enabled: false # enforce_referential_integrity_on_delete: false # This is an experimental feature, and does not fully support _total and other FHIR features. # enforce_referential_integrity_on_delete: false From 7cd0637c88b0f8d8d8679d0dbf31bfa27e6c7bf2 Mon Sep 17 00:00:00 2001 From: Michal Sevcik <99325737+SevcikMichal@users.noreply.github.com> Date: Sun, 8 Jun 2025 11:40:26 +0200 Subject: [PATCH 2/4] Enable configuration of store_meta_source_information (#825) * Enable configuration of store_meta_source_information * Update src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java Co-authored-by: James Agnew * Apply spotless style checks --------- Co-authored-by: James Agnew --- .../java/ca/uhn/fhir/jpa/starter/AppProperties.java | 12 ++++++++++++ .../jpa/starter/common/FhirServerConfigCommon.java | 4 ++++ src/main/resources/application.yaml | 3 ++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java b/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java index 05f90b9..34b0c75 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java @@ -1,6 +1,7 @@ package ca.uhn.fhir.jpa.starter; import ca.uhn.fhir.context.FhirVersionEnum; +import ca.uhn.fhir.jpa.api.config.JpaStorageSettings; import ca.uhn.fhir.jpa.api.config.JpaStorageSettings.ClientIdStrategyEnum; import ca.uhn.fhir.jpa.api.config.JpaStorageSettings.IdStrategyEnum; import ca.uhn.fhir.jpa.model.entity.NormalizedQuantitySearchLevel; @@ -106,6 +107,8 @@ public class AppProperties { private Integer pre_expand_value_sets_default_count = 1000; private Integer pre_expand_value_sets_max_count = 1000; private Integer maximum_expansion_size = 1000; + private JpaStorageSettings.StoreMetaSourceInformationEnum store_meta_source_information = + JpaStorageSettings.StoreMetaSourceInformationEnum.NONE; private Map remote_terminology_service = null; @@ -742,6 +745,15 @@ public class AppProperties { this.remote_terminology_service = remote_terminology_service; } + public JpaStorageSettings.StoreMetaSourceInformationEnum getStore_meta_source_information() { + return store_meta_source_information; + } + + public void setStore_meta_source_information( + JpaStorageSettings.StoreMetaSourceInformationEnum store_meta_source_information) { + this.store_meta_source_information = store_meta_source_information; + } + public static class Cors { private Boolean allow_Credentials = true; private List allowed_origin = List.of("*"); diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java b/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java index 9c2007f..60f9948 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java @@ -254,6 +254,10 @@ public class FhirServerConfigCommon { jpaStorageSettings.setBundleBatchPoolSize(appProperties.getBundle_batch_pool_size()); jpaStorageSettings.setBundleBatchPoolSize(appProperties.getBundle_batch_pool_max_size()); + // Set store meta source information + ourLog.debug("Server configured to Store Meta Source: {}", appProperties.getStore_meta_source_information()); + jpaStorageSettings.setStoreMetaSourceInformation(appProperties.getStore_meta_source_information()); + storageSettings(appProperties, jpaStorageSettings); return jpaStorageSettings; } diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 849a6fa..cb0c0ce 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -276,7 +276,8 @@ hapi: # classes listed here will be fetched from the Spring context when combined with 'custom-bean-packages', # or will be instantiated via reflection using an no-arg contructor; then registered with the server #custom-provider-classes: - + # specify what should be stored in meta.source based on StoreMetaSourceInformationEnum defaults to NONE + # store_meta_source_information: NONE # Threadpool size for BATCH'ed GETs in a bundle. # bundle_batch_pool_size: 10 # bundle_batch_pool_max_size: 50 From 0690d803c6c0890241dad2c101397604bea8605c Mon Sep 17 00:00:00 2001 From: Brenin Rhodes Date: Wed, 18 Jun 2025 18:22:19 -0600 Subject: [PATCH 3/4] bump cr to 3-22-0 --- pom.xml | 2 +- .../uhn/fhir/jpa/starter/cdshooks/UpdatedCdsCrService.java | 7 +++---- .../jpa/starter/cdshooks/UpdatedCrDiscoveryService.java | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 356ab2c..e7c4f12 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 17 1 - 3.21.0 + 3.22.0 diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/cdshooks/UpdatedCdsCrService.java b/src/main/java/ca/uhn/fhir/jpa/starter/cdshooks/UpdatedCdsCrService.java index 414993c..9a256af 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/cdshooks/UpdatedCdsCrService.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/cdshooks/UpdatedCdsCrService.java @@ -1,12 +1,11 @@ package ca.uhn.fhir.jpa.starter.cdshooks; import ca.uhn.fhir.context.FhirVersionEnum; +import ca.uhn.fhir.repository.IRepository; import ca.uhn.fhir.rest.api.server.RequestDetails; import ca.uhn.fhir.rest.api.server.cdshooks.CdsServiceRequestJson; -import ca.uhn.hapi.fhir.cdshooks.api.ICdsConfigService; import org.hl7.fhir.instance.model.api.IBaseParameters; import org.hl7.fhir.instance.model.api.IPrimitiveType; -import org.opencds.cqf.fhir.api.Repository; import org.opencds.cqf.fhir.cr.hapi.cdshooks.CdsCrService; import org.opencds.cqf.fhir.utility.adapter.IAdapterFactory; @@ -16,8 +15,8 @@ public class UpdatedCdsCrService extends CdsCrService { private final IAdapterFactory adapterFactory; public UpdatedCdsCrService( - RequestDetails theRequestDetails, Repository theRepository, ICdsConfigService theCdsConfigService) { - super(theRequestDetails, theRepository, theCdsConfigService); + RequestDetails theRequestDetails, IRepository theRepository) { + super(theRequestDetails, theRepository); adapterFactory = IAdapterFactory.forFhirContext(theRepository.fhirContext()); } diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/cdshooks/UpdatedCrDiscoveryService.java b/src/main/java/ca/uhn/fhir/jpa/starter/cdshooks/UpdatedCrDiscoveryService.java index f01873e..2bc82f0 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/cdshooks/UpdatedCrDiscoveryService.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/cdshooks/UpdatedCrDiscoveryService.java @@ -1,11 +1,11 @@ package ca.uhn.fhir.jpa.starter.cdshooks; +import ca.uhn.fhir.repository.IRepository; import org.hl7.fhir.instance.model.api.IIdType; -import org.opencds.cqf.fhir.api.Repository; import org.opencds.cqf.fhir.cr.hapi.cdshooks.discovery.CrDiscoveryService; public class UpdatedCrDiscoveryService extends CrDiscoveryService { - public UpdatedCrDiscoveryService(IIdType thePlanDefinitionId, Repository theRepository) { + public UpdatedCrDiscoveryService(IIdType thePlanDefinitionId, IRepository theRepository) { super(thePlanDefinitionId, theRepository); maxUriLength = 6000; } From 4f9a84db9710f328d34ab0a554bb99c01f0fdc18 Mon Sep 17 00:00:00 2001 From: Brenin Rhodes Date: Wed, 18 Jun 2025 18:25:36 -0600 Subject: [PATCH 4/4] spotless --- .../ca/uhn/fhir/jpa/starter/cdshooks/UpdatedCdsCrService.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/cdshooks/UpdatedCdsCrService.java b/src/main/java/ca/uhn/fhir/jpa/starter/cdshooks/UpdatedCdsCrService.java index 9a256af..4319fa8 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/cdshooks/UpdatedCdsCrService.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/cdshooks/UpdatedCdsCrService.java @@ -14,8 +14,7 @@ import static org.opencds.cqf.fhir.utility.Constants.APPLY_PARAMETER_DATA; public class UpdatedCdsCrService extends CdsCrService { private final IAdapterFactory adapterFactory; - public UpdatedCdsCrService( - RequestDetails theRequestDetails, IRepository theRepository) { + public UpdatedCdsCrService(RequestDetails theRequestDetails, IRepository theRepository) { super(theRequestDetails, theRepository); adapterFactory = IAdapterFactory.forFhirContext(theRepository.fhirContext()); }