-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
index judge names as text for use with advanced search
- Loading branch information
1 parent
84f40c9
commit 60ad48c
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
peachjam_search/migrations/0005_es_mapping_add_judges_text.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import os | ||
|
||
from django.db import migrations | ||
|
||
|
||
def forwards(apps, schema_editor): | ||
from django.conf import settings | ||
from django_elasticsearch_dsl.registries import registry | ||
|
||
if not settings.DEBUG and os.environ.get("ELASTICSEARCH_HOST"): | ||
for ix in registry.get_indices(): | ||
if not ix._mapping: | ||
continue | ||
print(f"Adding judges_text mapping for {ix._name}") | ||
ix.connection.indices.put_mapping( | ||
index=ix._name, | ||
body={ | ||
"properties": {"judges_text": ix._mapping["judges_text"].to_dict()} | ||
}, | ||
) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("peachjam_search", "0004_auto_20240719_1050"), | ||
] | ||
|
||
operations = [migrations.RunPython(forwards, migrations.RunPython.noop)] |