I recently updated from Wagtail 2.13.5 to 3.0.3. After the update, the search()
method on Wagtail's PageQuerySet
returns no results for search terms that clearly should return results (and which do when using the older version).
For example, under 2.13, where search_backend
is an instance of wagtail.contrib.postgres_search.backend.PostgresSearchBackend
, and qs
is an instance of wagtail.core.query.PageQuerySet
the following returns lots of results:
search_backend.search('popular-search-term', qs, fields=None, operator=None, order_by_relevance=True, partial_match=True)
But under 3.0.3, where search_backend
is now an instance of wagtail.search.backends.database.postgres.postgres.PostgresSearchBackend
and qs
is an instance of wagtail.query.PageQuerySet
, the same call to search()
will return nothing (an empty queryset).
The data in the qs
queryset is the same in both cases, so maybe I'm missing something in my configuration of the search backend? My "settings.py" file has:
WAGTAILSEARCH_BACKENDS = {
'default': {
'BACKEND': 'wagtail.search.backends.database',
'SEARCH_CONFIG': 'english',
},
}
and
INSTALLED_APPS = [
...
'wagtail.search',
'wagtail.search.backends.database.postgres',
...
]
I had to guess at the value for 'wagtail.search.backends.database.postgres'. AFAICT, Wagtail's docs don't mention what should go into INSTALLED_APPS
. But the pre-upgrade value of 'wagtail.contrib.postgres_search' would clearly be wrong, as that module has been removed.
Anyone got an idea why calling search()
on a PageQuerySet
would incorrectly return no results?
CodePudding user response:
The steps for changing the search backend are documented at https://docs.wagtail.org/en/stable/releases/2.15.html#database-search-backends-replaced. In particular:
- You should remove
wagtail.contrib.postgres_search
from INSTALLED_APPS, and do not need to add anything in its place - the existingwagtail.search
app is sufficient - After changing over, you need to re-run the
./manage.py update_index
command to ensure that the new search index is populated.