Config Elasticsearch
This commit is contained in:
parent
dd63191ffd
commit
402a46ab74
5 changed files with 66 additions and 0 deletions
18
README.md
18
README.md
|
@ -39,6 +39,24 @@ Vous pouvez alors lancez le serveur de développement
|
|||
|
||||
python manage.py runserver
|
||||
|
||||
## Configuration de la recherche
|
||||
|
||||
Il faut installer elasticsearch 5.*. C'est compliqué. Mais en suivant https://www.elastic.co/guide/en/elasticsearch/reference/5.4/deb.html ça va.
|
||||
|
||||
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
|
||||
sudo apt-get install apt-transport-https
|
||||
echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list
|
||||
sudo apt-get update && sudo apt-get install elasticsearch
|
||||
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable elasticsearch.service
|
||||
sudo systemctl start elasticsearch.service
|
||||
|
||||
Et puis, de retour dans le virtualenv python
|
||||
|
||||
python manage.py search_index --rebuild
|
||||
|
||||
Si des erreurs s'affichent, il y a une cachuète dans le beurre.
|
||||
|
||||
## Changer le CSS
|
||||
|
||||
|
|
39
avisstage/documents.py
Normal file
39
avisstage/documents.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
from django_elasticsearch_dsl import DocType, Index, fields
|
||||
from .models import Stage, AvisStage, AvisLieu
|
||||
|
||||
stage = Index('stages')
|
||||
stage.settings(
|
||||
number_of_shards=1,
|
||||
number_of_replicas=0
|
||||
)
|
||||
|
||||
@stage.doc_type
|
||||
class StageDocument(DocType):
|
||||
lieux = fields.ObjectField(properties={
|
||||
'nom': fields.StringField(),
|
||||
'pays': fields.StringField(),
|
||||
})
|
||||
thematiques = fields.StringField()
|
||||
matieres = fields.StringField()
|
||||
|
||||
class Meta:
|
||||
model = Stage
|
||||
fields = [
|
||||
'sujet',
|
||||
'encadrants',
|
||||
'type_stage',
|
||||
'niveau_scol',
|
||||
'structure'
|
||||
]
|
||||
|
||||
def prepare_thematiques(self, instance):
|
||||
return ", ".join(instance.thematiques.all().values_list("slug", flat=True))
|
||||
|
||||
def prepare_matieres(self, instance):
|
||||
return ", ".join(instance.matieres.all().values_list("slug", flat=True))
|
||||
|
||||
def prepare_niveau_scol(self, instance):
|
||||
return instance.get_niveau_scol_display()
|
||||
|
||||
def prepare_type_stage(self, instance):
|
||||
return instance.type_stage_fancy
|
|
@ -30,6 +30,8 @@ INSTALLED_APPS = (
|
|||
'django.contrib.staticfiles',
|
||||
'django.contrib.gis',
|
||||
|
||||
'django_elasticsearch_dsl',
|
||||
|
||||
'tastypie',
|
||||
'django_cas_ng',
|
||||
'braces',
|
||||
|
|
|
@ -26,3 +26,9 @@ STATIC_ROOT = "/home/evarin/Bureau/experiENS/static/"
|
|||
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
||||
|
||||
STATIC_URL = "/experiens/static/"
|
||||
|
||||
ELASTICSEARCH_DSL = {
|
||||
'default': {
|
||||
'hosts': 'localhost:9200'
|
||||
},
|
||||
}
|
||||
|
|
|
@ -8,3 +8,4 @@ django-taggit-autosuggest
|
|||
pytz
|
||||
django-tastypie
|
||||
lxml
|
||||
git+https://github.com/sabricot/django-elasticsearch-dsl
|
||||
|
|
Loading…
Reference in a new issue