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

  1. Read query from request params.
  2. If query is present, execute Page.objects.live().search(query).
  3. If query is empty, return an empty result set.
  4. Paginate with 10 results per page.
  5. If page is invalid, fall back to page 1.
  6. Render search/search.html with search_query and search_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.