Feature/elastic back in green (#893)
* Getting automated tests back into green * using native API's * formatting * refactoring * getting 8.X ES working * Removed sleep * Update src/test/java/ca/uhn/fhir/jpa/starter/ElasticsearchLastNR4IT.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Reintroduced sleep as indicies are a bit slow ? * Using the production bean instead of a test one * updating default parameters for es * Making separate profile for ES * works from here * remove all not needed code anymore * removing parent defined version * fixed tests --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
c5fd867efc
commit
78a068ab45
@@ -50,6 +50,7 @@ import ca.uhn.fhir.jpa.starter.AppProperties;
|
||||
import ca.uhn.fhir.jpa.starter.annotations.OnCorsPresent;
|
||||
import ca.uhn.fhir.jpa.starter.annotations.OnImplementationGuidesPresent;
|
||||
import ca.uhn.fhir.jpa.starter.common.validation.IRepositoryValidationInterceptorFactory;
|
||||
import ca.uhn.fhir.jpa.starter.elastic.ElasticsearchBootSvcImpl;
|
||||
import ca.uhn.fhir.jpa.starter.ig.ExtendedPackageInstallationSpec;
|
||||
import ca.uhn.fhir.jpa.starter.ig.IImplementationGuideOperationProvider;
|
||||
import ca.uhn.fhir.jpa.subscription.util.SubscriptionDebugLogInterceptor;
|
||||
@@ -149,6 +150,7 @@ public class StarterJpaConfig {
|
||||
@Primary
|
||||
@Bean
|
||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
|
||||
Optional<ElasticsearchBootSvcImpl> elasticsearchSvc,
|
||||
JpaProperties theJpaProperties,
|
||||
DataSource myDataSource,
|
||||
ConfigurableListableBeanFactory myConfigurableListableBeanFactory,
|
||||
|
||||
@@ -50,7 +50,7 @@ public class ElasticsearchBootSvcImpl implements IElasticsearchSvc {
|
||||
|
||||
private static final String OBSERVATION_RESOURCE_NAME = "Observation";
|
||||
|
||||
private final ElasticsearchClient myRestHighLevelClient;
|
||||
private final ElasticsearchClient myElasticsearchClient;
|
||||
|
||||
private final FhirContext myContext;
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ElasticsearchBootSvcImpl implements IElasticsearchSvc {
|
||||
public ElasticsearchBootSvcImpl(ElasticsearchClient client, FhirContext fhirContext, AppProperties appProperties) {
|
||||
|
||||
myContext = fhirContext;
|
||||
myRestHighLevelClient = client;
|
||||
myElasticsearchClient = client;
|
||||
|
||||
// Determine index prefix from configuration
|
||||
if (appProperties.getElasticsearch() != null) {
|
||||
@@ -144,7 +144,7 @@ public class ElasticsearchBootSvcImpl implements IElasticsearchSvc {
|
||||
}
|
||||
|
||||
private boolean createIndex(String theIndexName, String theMapping) throws IOException {
|
||||
return myRestHighLevelClient
|
||||
return myElasticsearchClient
|
||||
.indices()
|
||||
.create(cir -> cir.index(theIndexName).withJson(new StringReader(theMapping)))
|
||||
.acknowledged();
|
||||
@@ -152,7 +152,7 @@ public class ElasticsearchBootSvcImpl implements IElasticsearchSvc {
|
||||
|
||||
private boolean indexExists(String theIndexName) throws IOException {
|
||||
ExistsRequest request = new ExistsRequest.Builder().index(theIndexName).build();
|
||||
return myRestHighLevelClient.indices().exists(request).value();
|
||||
return myElasticsearchClient.indices().exists(request).value();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -165,7 +165,7 @@ public class ElasticsearchBootSvcImpl implements IElasticsearchSvc {
|
||||
SearchRequest searchRequest = buildObservationResourceSearchRequest(thePids);
|
||||
try {
|
||||
SearchResponse<ObservationJson> observationDocumentResponse =
|
||||
myRestHighLevelClient.search(searchRequest, ObservationJson.class);
|
||||
myElasticsearchClient.search(searchRequest, ObservationJson.class);
|
||||
List<Hit<ObservationJson>> observationDocumentHits =
|
||||
observationDocumentResponse.hits().hits();
|
||||
IParser parser = TolerantJsonParser.createWithLenientErrorHandling(myContext, null);
|
||||
@@ -202,7 +202,7 @@ public class ElasticsearchBootSvcImpl implements IElasticsearchSvc {
|
||||
|
||||
@VisibleForTesting
|
||||
public void refreshIndex(String theIndexName) throws IOException {
|
||||
myRestHighLevelClient.indices().refresh(fn -> fn.index(theIndexName));
|
||||
myElasticsearchClient.indices().refresh(fn -> fn.index(theIndexName));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user