Search
Purpose
/search/ provides full-site content discovery by querying live Wagtail pages and returning paginated results.
Scope
In scope: - Search request handling and query behavior. - Pagination and fallback behavior for invalid page values. - Template rendering for search results.
Out of scope: - Search ranking tuning and promoted result logic. - New search backends.
Behavior
- Read
queryfrom request params. - If query is present, execute
Page.objects.live().search(query). - If query is empty, return an empty result set.
- Paginate with 10 results per page.
- If
pageis invalid, fall back to page 1. - Render
search/search.htmlwithsearch_queryandsearch_results.
Code locations
- View:
backend/search/views.py - URL route:
backend/backend/urls.py - Template:
backend/search/templates/search/search.html - Tests:
backend/search/tests.py
How to verify
Manual:
- GET /search/?query=hello
- GET /search/?query=hello&page=not-a-number
Automated:
- make test
- Optional targeted run: docker compose run --rm web python manage.py test search.tests.SearchViewTests
Failure modes to watch
- Search index not updated in tests, causing missing results.
- Pagination behavior regresses and invalid page values raise errors.
- Template changes expect context keys that are no longer provided.