diff --git a/wagtail/contrib/postgres_search/backend.py b/wagtail/contrib/postgres_search/backend.py index a824a5ef66..30b14317a1 100644 --- a/wagtail/contrib/postgres_search/backend.py +++ b/wagtail/contrib/postgres_search/backend.py @@ -168,10 +168,10 @@ class Index(object): obj._object_id = force_text(obj.pk) obj._body_ = self.prepare_body(obj) connection = connections[self.db_alias] - # if connection.pg_version >= 90500: # PostgreSQL >= 9.5 - # self.add_items_upsert(connection, content_type_pk, objs, config) - # else: - self.add_items_update_then_create(content_type_pk, objs, config) + if connection.pg_version >= 90500: # PostgreSQL >= 9.5 + self.add_items_upsert(connection, content_type_pk, objs, config) + else: + self.add_items_update_then_create(content_type_pk, objs, config) def __str__(self): return self.name @@ -331,7 +331,7 @@ class PostgresSearchBackend(BaseSearchBackend): self.get_index_for_object(obj_list[0]).add_items(model, obj_list) def delete(self, obj): - obj.index_entries.delete() + obj.index_entries.all().delete() SearchBackend = PostgresSearchBackend