feat: food search sheet with FTS+trgm, dish/recent endpoints, multilingual aliases
Backend: - GET /dishes/search — hybrid FTS (english + simple) + trgm + ILIKE search - GET /diary/recent — recently used dishes and products for the current user - product search upgraded: FTS on canonical_name and product_aliases, ranked by GREATEST(ts_rank, similarity) - importoff: collect product_name_ru/de/fr/... as product_aliases for multilingual search (e.g. "сникерс" → "Snickers") - migrations: FTS + trgm indexes merged into 001_initial_schema.sql (002 removed) Flutter: - FoodSearchSheet: debounced search field, recently-used section, product/dish results, scan-photo and barcode chips - DishPortionSheet: quick ½/1/1½/2 buttons + custom input - + button in meal card now opens FoodSearchSheet instead of going directly to AI scan - 7 new l10n keys across all 12 languages Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -141,6 +141,7 @@ CREATE TABLE products (
|
||||
CREATE INDEX idx_products_canonical_name ON products (canonical_name);
|
||||
CREATE INDEX idx_products_category ON products (category);
|
||||
CREATE INDEX idx_products_barcode ON products (barcode) WHERE barcode IS NOT NULL;
|
||||
CREATE INDEX idx_products_fts ON products USING GIN (to_tsvector('english', canonical_name));
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- product_aliases
|
||||
@@ -153,6 +154,7 @@ CREATE TABLE product_aliases (
|
||||
);
|
||||
CREATE INDEX idx_product_aliases_lookup ON product_aliases (product_id, lang);
|
||||
CREATE INDEX idx_product_aliases_trgm ON product_aliases USING GIN (alias gin_trgm_ops);
|
||||
CREATE INDEX idx_product_aliases_fts ON product_aliases USING GIN (to_tsvector('simple', alias));
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- cuisines + cuisine_translations
|
||||
@@ -217,9 +219,11 @@ CREATE TABLE dishes (
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
);
|
||||
CREATE INDEX idx_dishes_cuisine ON dishes (cuisine_slug);
|
||||
CREATE INDEX idx_dishes_category ON dishes (category_slug);
|
||||
CREATE INDEX idx_dishes_rating ON dishes (avg_rating DESC);
|
||||
CREATE INDEX idx_dishes_cuisine ON dishes (cuisine_slug);
|
||||
CREATE INDEX idx_dishes_category ON dishes (category_slug);
|
||||
CREATE INDEX idx_dishes_rating ON dishes (avg_rating DESC);
|
||||
CREATE INDEX idx_dishes_name_fts ON dishes USING GIN (to_tsvector('english', name));
|
||||
CREATE INDEX idx_dishes_name_trgm ON dishes USING GIN (name gin_trgm_ops);
|
||||
|
||||
CREATE TABLE dish_translations (
|
||||
dish_id UUID NOT NULL REFERENCES dishes(id) ON DELETE CASCADE,
|
||||
@@ -228,6 +232,8 @@ CREATE TABLE dish_translations (
|
||||
description TEXT,
|
||||
PRIMARY KEY (dish_id, lang)
|
||||
);
|
||||
CREATE INDEX idx_dish_translations_name_fts ON dish_translations USING GIN (to_tsvector('simple', name));
|
||||
CREATE INDEX idx_dish_translations_name_trgm ON dish_translations USING GIN (name gin_trgm_ops);
|
||||
|
||||
CREATE TABLE dish_tags (
|
||||
dish_id UUID NOT NULL REFERENCES dishes(id) ON DELETE CASCADE,
|
||||
|
||||
Reference in New Issue
Block a user