Skip to content

Commit

Permalink
#287 - Elastic search connection
Browse files Browse the repository at this point in the history
- add a switch to turn elastic search on or off
  • Loading branch information
michael-82 committed May 17, 2024
1 parent 8b71d04 commit 5e67a32
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/integration-test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ services:
API_BASE_URL: "http://localhost:8091/api/"
ALLOWED_ORIGINS: "https://localhost"
QUERYRESULT_EXPIRY_MINUTES: 5
ELASTIC_SEARCH_ENABLED: "false"
# ---- db config
FEASIBILITY_DATABASE_HOST: "feasibility-gui-backend-db"
FEASIBILITY_DATABASE_PORT: 5432
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package de.numcodex.feasibility_gui_backend.terminology.es.config;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.client.ClientConfiguration;
import org.springframework.data.elasticsearch.client.elc.ElasticsearchConfiguration;

@Configuration
@ConditionalOnExpression("${app.elasticSearchEnabled}")
public class Config extends ElasticsearchConfiguration {

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package de.numcodex.feasibility_gui_backend.terminology.es.repository;

import de.numcodex.feasibility_gui_backend.terminology.es.model.OntologyItemDocument;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;

@ConditionalOnExpression("${app.elasticSearchEnabled}")
public interface OntologyItemEsRepository extends ElasticsearchRepository<OntologyItemDocument, String> {}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import de.numcodex.feasibility_gui_backend.terminology.es.model.OntologyItemDocument;
import de.numcodex.feasibility_gui_backend.terminology.es.model.OntologyListItemDocument;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.data.elasticsearch.client.elc.NativeQuery;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
import org.springframework.data.elasticsearch.core.SearchHits;
Expand All @@ -15,6 +16,7 @@

@RestController
@RequestMapping("api/v3/terminology/search")
@ConditionalOnExpression("${app.elasticSearchEnabled}")
public class TerminologyEsController {

private ElasticsearchOperations operations;
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ management:
endpoint:
health:
enabled: true
health:
elasticsearch:
enabled: ${ELASTIC_SEARCH_ENABLED:true}

app:
# AKTIN or DSF or MOCK or DIRECT
Expand All @@ -52,6 +55,7 @@ app:
keycloakAdminRole: ${KEYCLOAK_ADMIN_ROLE:FeasibilityAdmin}
queryResultExpiryMinutes: ${QUERYRESULT_EXPIRY_MINUTES:1}
maxSavedQueriesPerUser: ${MAX_SAVED_QUERIES_PER_USER:10}
elasticSearchEnabled: ${ELASTIC_SEARCH_ENABLED:true}
broker:
mock:
enabled: ${BROKER_CLIENT_MOCK_ENABLED:false}
Expand Down
5 changes: 5 additions & 0 deletions src/test/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ security:
config:
use-keycloak: false

management:
health:
elasticsearch:
enabled: false
app:
queryResultExpiryMinutes: 1
keycloakAllowedRole: "FEASIBILITY_TEST_USER"
keycloakPowerRole: "FEASIBILITY_TEST_POWER"
keycloakAdminRole: "FEASIBILITY_TEST_ADMIN"
maxSavedQueriesPerUser: 2
elasticSearchEnabled: false
broker:
aktin:
enabled: false
Expand Down

0 comments on commit 5e67a32

Please sign in to comment.