Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP fulltext index #423

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions chicago/migrations/0006_searchbill.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 3.2.25 on 2024-11-22 21:59

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('chicago', '0005_chicagopersonstatistic_legislation_success_rate'),
]

operations = [
migrations.CreateModel(
name='SearchBill',
fields=[
('text', models.TextField()),
('last_updated', models.DateTimeField(auto_now_add=True)),
('bill', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to='chicago.chicagobill')),
],
),
]
18 changes: 18 additions & 0 deletions chicago/migrations/0007_searchbill_extras.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.25 on 2024-12-13 21:38

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('chicago', '0006_searchbill'),
]

operations = [
migrations.AddField(
model_name='searchbill',
name='extras',
field=models.JSONField(null=True),
),
]
7 changes: 7 additions & 0 deletions chicago/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ def full_text_doc_url(self):
return None


class SearchBill(models.Model):
text = models.TextField()
last_updated = models.DateTimeField(auto_now_add=True, blank=True)
extras = models.JSONField(null=True)
bill = models.OneToOneField(ChicagoBill, on_delete=models.CASCADE, primary_key=True)


class ChicagoOrganization(Organization):
class Meta:
proxy = True
Expand Down
5 changes: 2 additions & 3 deletions chicago/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@

HAYSTACK_CONNECTIONS = {}
HAYSTACK_CONNECTIONS["default"] = {
"ENGINE": "haystack.backends.elasticsearch7_backend.Elasticsearch7SearchEngine",
"URL": os.getenv("HAYSTACK_URL", "http://elasticsearch:9200"),
"INDEX_NAME": "chicago",
"ENGINE": "postgres_fts_backend.PostgresFTSEngine",
"INDEX_NAME": "chicago_fts",
"SILENTLY_FAIL": False,
"BATCH_SIZE": 10,
}
Expand Down
29 changes: 14 additions & 15 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ services:
depends_on:
postgres:
condition: service_healthy
elasticsearch:
condition: service_started
volumes:
- .:/app
- /Users/derekeder/projects/datamade/postgres-fts-backend:/postgres-fts-backend
environment:
DJANGO_MANAGEPY_MIGRATE: "False"
DJANGO_DEBUG: "True"
Expand All @@ -40,19 +39,19 @@ services:
ports:
- 32001:5432

elasticsearch:
image: elasticsearch:7.14.2
container_name: chi-councilmatic-elasticsearch
ports:
- 9200:9200
environment:
- discovery.type=single-node
- logger.org.elasticsearch.discovery=DEBUG
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
mem_limit: 1g
volumes:
- chi-councilmatic-es-data:/usr/share/elasticsearch/data
# elasticsearch:
# image: elasticsearch:7.14.2
# container_name: chi-councilmatic-elasticsearch
# ports:
# - 9200:9200
# environment:
# - discovery.type=single-node
# - logger.org.elasticsearch.discovery=DEBUG
# - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
# mem_limit: 1g
# volumes:
# - chi-councilmatic-es-data:/usr/share/elasticsearch/data

volumes:
chi-councilmatic-db-data:
chi-councilmatic-es-data:
# chi-councilmatic-es-data:
2 changes: 2 additions & 0 deletions scripts/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/sh
set -e

pip install -e /postgres-fts-backend

if [ "$DJANGO_MANAGEPY_MIGRATE" = "True" ]; then
python manage.py migrate --noinput
fi
Expand Down
Loading