Rebasely Beta: data may be purged

examplesstorefront Public

Search the catalog with D1 full text search #4

Changed files

21 files changed404 additions24 deletionssince main at f6403bb

Searching the catalog

Added by this pull request.

  • Added
  • Rerouted, relabelled or moved
  • Removed

The merchant renames a product, and a shopper searches for it a moment later. Every product write updates the product's row in the search index, a separate D1 database. A search matches in the index, then reads the products from the catalog, so prices, stock and retired products are always current.

Searching the catalog: 9 steps between 5 participants Step 1: merchant to storefront-api, PUT /admin/products/linen-apron, admin token (added)PUT /admin/products/linen-apr…Step 2: storefront-api to db, upsert the product (added)upsert the productStep 3: storefront-api to search, one batch: delete the product's row, insert its name and description (added)one batch: delete the product's row, insert …Step 4: storefront-api to merchant, the product, or 503 search_index_failed to retry (added)the product, or 503 search_in…Step 5: shopper to storefront-api, GET /search?q=linen apr (added)GET /search?q=linen aprStep 6: storefront-api to search, MATCH '"linen" "apr"*', ranked by bm25, name weighted 10 (added)MATCH '"linen" "apr"*', ranked by bm25, name…Step 7: search to storefront-api, product ids, best match first (added)product ids, best match firstStep 8: storefront-api to db, read those products, active ones only (added)read those products, active o…Step 9: storefront-api to shopper, the products in match order, with current price and stock (added)the products in match order, with current price and stockmerchant (added in this flow)merchantActor · addedstorefront-api (added in this flow)storefront-apiWorker · addeddb (added in this flow)dbD1 database · addedsearch (added in this flow)searchD1 database · addedshopper (added in this flow)shopperActor · added

The flow catalog-search at the head of this pull request, numbered in its order, with the steps it adds, reroutes, relabels, moves and removes. A removed step has no number.

Steps

  1. Step 1, added: merchant → storefront-api PUT /admin/products/linen-apron, admin token Added
  2. Step 2, added: storefront-api → db upsert the product Added
  3. Step 3, added: storefront-api → search one batch: delete the product's row, insert its name and description Added
  4. Step 4, added: storefront-api → merchant the product, or 503 search_index_failed to retry Added
  5. Step 5, added: shopper → storefront-api GET /search?q=linen apr Added
  6. Step 6, added: storefront-api → search MATCH '"linen" "apr"*', ranked by bm25, name weighted 10 Added
  7. Step 7, added: search → storefront-api product ids, best match first Added
  8. Step 8, added: storefront-api → db read those products, active ones only Added
  9. Step 9, added: storefront-api → shopper the products in match order, with current price and stock Added

Knowledge base

Back to the conversation