Skip to content

Commit

Permalink
Use index prefix from settings
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvarner committed Sep 18, 2024
1 parent e5acc7d commit f29dff7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
10 changes: 6 additions & 4 deletions apps/iiif/manifests/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@

from os import environ
from html import unescape

from django.conf import settings
from django.db.models.query import Prefetch
from django.utils.html import strip_tags

from django_elasticsearch_dsl import Document, fields
from django_elasticsearch_dsl.registries import registry

from elasticsearch_dsl import MetaField, Keyword, analyzer
from django.db.models.query import Prefetch
from django.utils.html import strip_tags
from unidecode import unidecode

from apps.iiif.annotations.models import Annotation
from apps.iiif.canvases.models import Canvas
from apps.iiif.kollections.models import Collection
from apps.iiif.manifests.models import Manifest

# TODO: Better English stemming (e.g. Rome to match Roman), multilingual stemming.
Expand Down Expand Up @@ -55,7 +57,7 @@ class ManifestDocument(Document):
class Index:
"""Settings for Elasticsearch"""

name = f"readux_{environ['DJANGO_ENV']}_manifests"
name = f"{settings.INDEX_PREFIX}_manifests"

class Django:
"""Settings for automatically pulling data from Django"""
Expand Down
3 changes: 2 additions & 1 deletion apps/readux/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django_elasticsearch_dsl import Document, fields
from django_elasticsearch_dsl.registries import registry
from django.utils.html import strip_tags
from django.conf import settings

from apps.readux.models import UserAnnotation
from apps.iiif.manifests.documents import stemmer
Expand All @@ -25,7 +26,7 @@ class UserAnnotationDocument(Document):
class Index:
"""Settings for Elasticsearch"""

name = f"readux_{environ['DJANGO_ENV']}_annotations"
name = f"{settings.INDEX_PREFIX}_annotations"

class Django:
"""Settings for automatically pulling data from Django"""
Expand Down
3 changes: 2 additions & 1 deletion config/settings/local.dst
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ LOGGING = {

# Must be configured to the host and port running Elasticsearch
ELASTICSEARCH_DSL['default']['hosts'] = 'user:pass@localhost:9200'
INDEX_PREFIX = "readux_test"

# Custom faceted metadata fields configuration. Must be a dict with key names
# matching exactly the ingest metadata spradsheet column names to be indexed.
Expand All @@ -179,7 +180,7 @@ ELASTICSEARCH_DSL['default']['hosts'] = 'user:pass@localhost:9200'
# used ("separator": ";", semicolon by default).
# Note that these key names will also correspond to "label" names in the Manifest
# metadata list.
#
#
# Example:
# CUSTOM_METADATA = {
# "Column Name": {
Expand Down

0 comments on commit f29dff7

Please sign in to comment.