diff --git a/docker-compose.yml b/docker-compose.yml index 7b19be74d..a990e5da7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,16 +11,17 @@ services: volumes: - sapldb_data:/var/lib/postgresql/data/ ports: - - "5432:5432" + - "5433:5432" saplsolr: image: solr:7.4-alpine restart: always + command: bin/solr start -c -f volumes: - solr_data:/opt/solr/server/solr - solr_configsets:/opt/solr/server/solr/configsets ports: - - "8983:8983" + - "8984:8983" sapl: image: interlegis/sapl:3.1.106-ALPHA @@ -35,6 +36,8 @@ services: EMAIL_HOST: smtp.dominio.net EMAIL_HOST_USER: usuariosmtp EMAIL_HOST_PASSWORD: senhasmtp + SOLR_CORE: sapl_bento_goncalves + SOLR_HOST: 10.1.10.192 SOLR_URL: http://saplsolr:8983/solr/sapl TZ: America/Sao_Paulo volumes: diff --git a/docker_solr_init.py b/docker_solr_init.py index 1573eba53..10bab3c69 100755 --- a/docker_solr_init.py +++ b/docker_solr_init.py @@ -89,14 +89,15 @@ if __name__ == '__main__': args = sys.argv if len(args) < 2: - print("Usage: python3 docker_solr_init.py ") + print("Usage: python3 docker_solr_init.py
") sys.exit(-1) core = args[1] client = SolrClient() if len(args) == 3: - hostname = args[2] - client = SolrClient(address=hostname) + address = args[2] + client = SolrClient(address=address) + if not client.exists_core(core): print("Core '%s' doesn't exists. Creating a new one..." % core) diff --git a/sapl/settings.py b/sapl/settings.py index 92a9fbcfa..7c2294fce 100644 --- a/sapl/settings.py +++ b/sapl/settings.py @@ -101,10 +101,27 @@ HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor' SEARCH_BACKEND = 'haystack.backends.whoosh_backend.WhooshEngine' SEARCH_URL = ('PATH', PROJECT_DIR.child('whoosh')) +USE_SOLR = config('USE_SOLR', cast=bool, default=False) SOLR_URL = config('SOLR_URL', cast=str, default='') -if SOLR_URL: +SOLR_HOST = config('SOLR_HOST', cast=str, default='localhost') +SOLR_CORE = config('SOLR_CORE', cast=str, default='sapl') + +if USE_SOLR: SEARCH_BACKEND = 'haystack.backends.solr_backend.SolrEngine' - SEARCH_URL = ('URL', config('SOLR_URL', cast=str)) + + if SOLR_URL: + SEARCH_URL = ('URL', SOLR_URL) + elif SOLR_HOST and SOLR_CORE: + SEARCH_URL = ('URL', 'http://{}:8983/solr/{}'.format(SOLR_HOST, SOLR_CORE)) + # elif SOLR_HOST: + # SEARCH_URL = ('URL', 'http://{}:8983/solr/sapl'.format(SOLR_HOST)) + # elif SOLR_CORE: + # SEARCH_URL = ('URL', 'http://localhost:8983/solr/sapl'.format(SOLR_CORE)) + else: + SEARCH_URL = ('URL', 'http://localhost:8983/solr/sapl') + + print("Solr URL: {}".format(SEARCH_URL[1])) + # ...or for multicore... # 'URL': 'http://127.0.0.1:8983/solr/mysite', diff --git a/solr/sapl_configset/conf/saplConfigSet.zip b/solr/sapl_configset/conf/saplConfigSet.zip new file mode 100644 index 000000000..67d96758c Binary files /dev/null and b/solr/sapl_configset/conf/saplConfigSet.zip differ