Add schema-agnostic PostgreSQL full-text search layer#220
Conversation
…ries Signed-off-by: Arup Chauhan <arupchauhan.connect@gmail.com>
Signed-off-by: Arup Chauhan <arupchauhan.connect@gmail.com>
|
Hello everyone, This PR adds the database-side search implementation layer using PostgreSQL full-text search and Scope is the DB search foundation: request search, user search, organization search, schema-agnostic migration execution, and local validation against both Virginia and Ireland-style schema clones. Fuzzy search is limited to the MVP search entities and fields: requests, users, and organizations. It is not applied globally to every table. The production scripts are shared across schemas through This PR also includes DB-side authorization-aware filtering in the search functions. QA/RDS validation is still pending because it requires QA database access, but the local validation runners pass for both schemas. |
Signed-off-by: Arup Chauhan <arupchauhan.connect@gmail.com>
Description
This PR adds the database-side search implementation layer for PostgreSQL-backed search across the Saayam database schemas. Ref Issue: #184 and part of #207
The goal is to provide the Phase 1 search foundation using native PostgreSQL full-text search and
pg_trgmfuzzy matching, while keeping the scripts schema-agnostic so theycan run against both the Virginia and Ireland database schemas through
search_path.The fuzzy search scope is intentionally limited to the MVP search entities: requests, users, and organizations. It is not applied globally to every table.
Context
This work follows the Saayam Search Implementation Plan and the database-side search requirements discussed for the search implementation layer.
Current scope:
pg_trgmFuzzy Search Scope
Fuzzy search is supported for the following entities and fields:
Requests:
request.req_subjrequest.req_descrequest.req_lochelp_categories.cat_namethrough request-category joinUsers:
users.full_nameusers.primary_email_addressOrganizations:
organizations.org_nameorganizations.city_nameNotes:
req_locis text-based location matching, not geo-distance filtering.Changes
Added search migration scripts under
ddl/Search/codes/:01_enable_fuzzy_search.sql02_add_request_search.sql03_add_user_and_volunteer_search.sql04_add_category_and_advanced_search.sqlAdded request search support:
search_vectoronrequesthelp_categories.cat_namereq_locsearch_requests(...)functionAdded user search support:
search_vectoronuserssearch_users(...)functionAdded organization search support:
search_organizations(...)functionAdded schema-agnostic execution:
search_pathsearch_pathtovirginia_dev_saayam_rdbmssearch_pathtoproposed_saayamAdded local validation setup under
ddl/Search/tests/:test_clones/runners/virginia_validation/ireland_validation/Behavior / Safety
No application or API behavior is changed in this PR.
The database search functions are additive and are introduced as callable DB-side search entry points.
Compatibility boundary:
search_path, not duplicated scripts.Authorization-aware filtering is included at the function level:
This is DB-side authorization-aware filtering, not the final production RBAC/session model. Final RBAC/session enforcement remains a backend and DevSecOps follow-up.
Risk boundary is moderate-low for local validation:
Validation
Executed and passing locally against a fresh Virginia-style test clone: