-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use psql full-text with a generated search vector field and an index on it
- Loading branch information
Showing
34 changed files
with
395 additions
and
35 deletions.
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
22 changes: 22 additions & 0 deletions
22
itou/users/migrations/0020_add_simple_unaccent_search_config.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,22 @@ | ||
# Generated by Django 5.1.4 on 2025-01-10 09:31 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("users", "0019_drop_jobseekerprofile_ata_allocation_since"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunSQL( | ||
"CREATE TEXT SEARCH CONFIGURATION simple_unaccent (COPY=simple);", | ||
reverse_sql="DROP TEXT SEARCH CONFIGURATION simple_unaccent;", | ||
), | ||
migrations.RunSQL( | ||
"ALTER TEXT SEARCH CONFIGURATION simple_unaccent " | ||
"ALTER MAPPING FOR hword, hword_part, word " | ||
"WITH unaccent,simple;", | ||
reverse_sql=migrations.RunSQL.noop, | ||
), | ||
] |
26 changes: 26 additions & 0 deletions
26
itou/users/migrations/0021_user_full_name_search_vector.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,26 @@ | ||
# Generated by Django 5.1.4 on 2025-01-10 14:38 | ||
|
||
import django.contrib.postgres.lookups | ||
import django.contrib.postgres.search | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("users", "0020_add_simple_unaccent_search_config"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="user", | ||
name="full_name_search_vector", | ||
field=models.GeneratedField( | ||
db_persist=True, | ||
expression=django.contrib.postgres.search.SearchVector( | ||
"first_name", "last_name", config="simple_unaccent" | ||
), | ||
output_field=django.contrib.postgres.search.SearchVectorField(), | ||
verbose_name="nom complet utilisé pour rechercher un utilisateur", | ||
), | ||
), | ||
] |
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,20 @@ | ||
# Generated by Django 5.1.4 on 2025-01-10 14:38 | ||
|
||
import django.contrib.postgres.indexes | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("users", "0021_user_full_name_search_vector"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddIndex( | ||
model_name="user", | ||
index=django.contrib.postgres.indexes.GinIndex( | ||
models.F("full_name_search_vector"), | ||
name="users_user_full_name_idx", | ||
), | ||
), | ||
] |
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
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
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
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
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
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
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
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
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
Oops, something went wrong.