From 2aa06a4355467962d479d763330ff5b5de8d38f5 Mon Sep 17 00:00:00 2001 From: Eduardo Calil Date: Thu, 11 May 2017 17:57:51 -0300 Subject: [PATCH] Fix #1061 substituir whoosh (#1064) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Migra para o solr * Melhora o README do Solr * Melhar o readme * Melhar o readme * Faz mudanças sugeridas * Usa Whoosh por default, ou solr se especificado no .env --- .gitignore | 1 + README.rst | 5 +++++ docs/solr.rst | 22 ++++++++++++++++++++++ requirements/requirements.txt | 1 + sapl/settings.py | 15 +++++++++++++-- 5 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 docs/solr.rst diff --git a/.gitignore b/.gitignore index b09b6cf6f..d66a04a22 100644 --- a/.gitignore +++ b/.gitignore @@ -96,3 +96,4 @@ whoosh/ solr-4.10.2/ postgres-data/ data/ +solr-*/ \ No newline at end of file diff --git a/README.rst b/README.rst index 1b9a45fc1..b149ad906 100644 --- a/README.rst +++ b/README.rst @@ -30,6 +30,11 @@ Instruções para Deploy `Deploy SAPL com Nginx + Gunicorn `_ +Instalação do Solr +====================== + `Instalação e configuração do Solr `_ + + Instruções para Tradução ======================== diff --git a/docs/solr.rst b/docs/solr.rst new file mode 100644 index 000000000..a81ee9d12 --- /dev/null +++ b/docs/solr.rst @@ -0,0 +1,22 @@ +================================ +Instruções para instalar o Solr +================================ + +Solr é a ferramenta utilizada pelo SAPL 3.1 para indexar documentos para que possa ser feita +a Pesquisa Textual. + + +Dentro do diretório principal siga os seguintes passos:: + + curl -LO https://archive.apache.org/dist/lucene/solr/4.10.2/solr-4.10.2.tgz + tar xvzf solr-4.10.2.tgz + cd solr-4.10.2 + cd example + java -jar start.jar + ./manage.py build_solr_schema --filename solr-4.10.2/example/solr/collection1/conf/schema.xml + + +Após isso, deve-se parar o servidor do Solr e restartar com ``java -jar start.jar`` + + +**OBS: Toda vez que o código da pesquisa textual for modificado, os comandos de build_solr_schema e start.jar devem ser rodados, nessa mesma ordem.** \ No newline at end of file diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 9c49a47f2..fb70f9368 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -28,6 +28,7 @@ pyyaml==3.11 rtyaml==0.0.3 textract==1.5.0 unipath==1.1 +pysolr==3.6.0 python-magic==0.4.12 gunicorn==19.6.0 django-reversion==2.0.8 diff --git a/sapl/settings.py b/sapl/settings.py index ed49f5d4d..694c12a95 100644 --- a/sapl/settings.py +++ b/sapl/settings.py @@ -84,11 +84,22 @@ INSTALLED_APPS = ( ) + SAPL_APPS +# FTS = Full Text Search +SEARCH_BACKEND = 'haystack.backends.whoosh_backend.WhooshEngine' +SEARCH_URL = ('PATH', PROJECT_DIR.child('whoosh')) + +SOLR_URL = config('SOLR_URL', cast=str, default='') +if SOLR_URL: + SEARCH_BACKEND = 'haystack.backends.solr_backend.SolrEngine' + SEARCH_URL = ('URL', config('SOLR_URL', cast=str)) + # ...or for multicore... + # 'URL': 'http://127.0.0.1:8983/solr/mysite', + HAYSTACK_CONNECTIONS = { 'default': { - 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine', - 'PATH': PROJECT_DIR.child('whoosh'), + 'ENGINE': SEARCH_BACKEND, + SEARCH_URL[0] : SEARCH_URL[1] }, }