Skip to content

Improve search result ranking and relevance ordering for campaign and donation queries #149

Description

@grantfox-oss

Context

The search service in src/services/search.service.ts currently uses simple contains matching and basic ordering. This works for basic lookup, but it does not rank results by relevance or make the ordering feel intuitive for users searching across campaigns and donations.

Problem statement

Implement a lightweight relevance ranking approach for search results so that more relevant campaign and donation matches appear earlier, while still preserving stable pagination and filtering behavior.

Current behavior

  • Campaign and donation searches use simple substring matching and sort by a single field such as creation date.
  • There is no relevance-based ranking beyond the raw query match.

Required behavior

  • Search results should be ordered by a simple relevance score derived from the query and the matched fields.
  • The ranking should remain deterministic and compatible with existing pagination.
  • The ranking should not make searches slower than the current basic implementation in a meaningful way.

Constraints

  • The change should stay within the current Prisma and service architecture.
  • No external search engine is required.

Acceptance criteria

  • Search results for a query return the most relevant matches first.
  • Pagination remains stable with the new ranking logic.
  • Unit tests cover ranking behavior for simple query cases.

Out of scope

  • Building a full-text search engine or semantic search system.
  • Rewriting the search API schema.

Hints and references

  • Review the current contains-based filters and the existing sort logic in the search service.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions