Skip to content

BE041 - Ranked and Paginated Product Search API - #219

Open
shshwtsuthar wants to merge 1 commit into
feature/search-fields-normalizationfrom
BE041-ranked-paginated-product-search
Open

shshwtsuthar wants to merge 1 commit into
feature/search-fields-normalizationfrom
BE041-ranked-paginated-product-search

Conversation

@shshwtsuthar

Copy link
Copy Markdown
Collaborator

Ticket

BE041 - Ranked and Paginated Product Search API

Description

Implemented the v1 backend product search API on top of BE040 search-field normalization.

  • Added GET /api/products/search with normalized q, bounded limit, opaque query-bound cursors, and sanitized error envelopes.
  • Uses an exact GTIN lookup for valid EAN-8, UPC-A, EAN-13, and GTIN-14 values; non-barcode queries make bounded reads against productNameSearch and brandSearch.
  • Merges sources by canonical barcode and ranks exact name, name prefix, exact brand, and brand prefix matches deterministically, with barcode as the final tie-breaker.
  • Returns compact product summaries, records only duration/outcome/result-count metrics, and does not log raw search terms.
  • Added v1 contract documentation, unit coverage, and Firestore emulator coverage for exact and normalized prefix retrieval.

This PR targets feature/search-fields-normalization and should merge after BE040 / PR #206.

Testing

cd mobile-app
npm test -- --runInBand __tests__/productSearchApi.test.ts __tests__/firestoreProductSearchRepository.test.ts

cd ..
npx firebase emulators:exec --project demo-food-remedy-be041 --only firestore "npm --prefix mobile-app test -- --runInBand __tests__/firestoreProductSearchRepository.test.ts"

Results: 14 route/contract tests passed; the emulator-only test is skipped outside the emulator; the Firestore emulator repository test passed.

Checks

  • All requirements of the ticket have been implemented, or I have commented on any exclusions
  • Unit tests have been added or updated for any backend changes (if applicable)
  • I have reviewed the Files Changed tab and verified it only contains relevant changes (comment if unsure about any)
  • This PR has been reviewed and approved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant