Add combined index for Postgres search backend. (#6548)

Fixes #6546
pull/6676/head
Will Giddens 2020-11-25 16:04:33 -05:00 zatwierdzone przez Matt Westcott
rodzic 3a5b7255ad
commit 2da410b2e0
4 zmienionych plików z 26 dodań i 0 usunięć

Wyświetl plik

@ -12,6 +12,7 @@ Changelog
* Added string representation to image Format class (Andreas Nüßlein)
* Support returning None from `register_page_action_menu_item` and `register_snippet_action_menu_item` to skip registering an item (Vadim Karpenko)
* Fields on a custom image model can now be defined as required / `blank=False` (Matt Westcott)
* Add combined index for Postgres search backend (Will Giddens)
* Fix: Stop menu icon overlapping the breadcrumb on small viewport widths in page editor (Karran Besen)
* Fix: Make sure document chooser pagination preserves the selected collection when moving between pages (Alex Sa)
* Fix: Gracefully handle oEmbed endpoints returning non-JSON responses (Matt Westcott)

Wyświetl plik

@ -35,6 +35,7 @@ Other features
* Added string representation to image Format class (Andreas Nüßlein)
* Support returning None from ``register_page_action_menu_item`` and ``register_snippet_action_menu_item`` to skip registering an item (Vadim Karpenko)
* Fields on a custom image model can now be defined as required / ``blank=False`` (Matt Westcott)
* Add combined index for Postgres search backend (Will Giddens)
Bug fixes

Wyświetl plik

@ -0,0 +1,22 @@
# Generated by Django 3.1.3 on 2020-11-13 16:55
from django.db import migrations
from wagtail.contrib.postgres_search.models import IndexEntry
table = IndexEntry._meta.db_table
class Migration(migrations.Migration):
dependencies = [
('postgres_search', '0003_title'),
]
operations = [
migrations.RunSQL(
'CREATE INDEX {0}_title_body_concat_search ON {0} '
'USING GIN(( title || body));'.format(table),
'DROP INDEX IF EXISTS {0}_title_body_concat_search;'.format(table),
),
]

Wyświetl plik

@ -60,6 +60,8 @@ class IndexEntry(models.Model):
unique_together = ('content_type', 'object_id')
verbose_name = _('index entry')
verbose_name_plural = _('index entries')
# An additional computed GIN index on 'title || body' is created in a SQL migration
# covers the default case of PostgresSearchQueryCompiler.get_index_vectors.
indexes = [GinIndex(fields=['autocomplete']),
GinIndex(fields=['title']),
GinIndex(fields=['body'])]