Skip to main content

Module catalog

Module catalog 

Source
Expand description

The normalized catalog: restaurants/stores, where they were seen from, menu categories and menu items, with FTS5 indexes for offline search.

Service crates map their upstream JSON into these rows and upsert them whenever they fetch list or menu data (see grabfood::index). Upserts never erase known data with unknowns: a field the new row doesn’t carry (e.g. cuisines in a “recommended” response) keeps its stored value.

Text search uses two external-content FTS5 tables per indexed table: unicode61 remove_diacritics 2 (whole words and prefixes; “cafe” finds “Café”) and trigram remove_diacritics 1 (substrings of ≥ 3 characters; “isig” finds “Sisig”). Word matches rank first (bm25), then trigram-only matches.

“Near” queries use a bounding box on indexed columns: restaurants whose coordinates are known (from menus), or that were seen from a delivery location near the point (restaurant_locations), then an exact haversine filter. Distance, ETA and fee come from the nearest sighting when there is one, since they depend on the delivery location.

Structs§

CategoryRow
A menu category / department.
ItemHit
An item from the catalog, with its restaurant.
ItemQuery
An item query.
ItemRow
A menu item (from a full menu, or a dish hit in search results).
Near
A point and radius for “near” queries.
RestaurantHit
A restaurant from the catalog. Location-dependent fields come from the sighting nearest the query point when there is one.
RestaurantQuery
A restaurant query. All fields are optional filters.
RestaurantRow
A restaurant or store, as seen in one response.

Functions§

effective_price
An item’s effective price: the discounted price when there is one.
haversine_km
Great-circle distance in km.
query_terms
Words of a free-text query (letters/digits only; FTS syntax is never passed through).