Rework search to return a list

Like a proper search would!"
This commit is contained in:
2024-08-13 17:41:01 +02:00
parent a6626761e7
commit 8fd8d53cc3
6 changed files with 61 additions and 32 deletions

View File

@@ -62,11 +62,12 @@ create table food(
);
create virtual table foodfix using spellfix1;
-- insert into foodfix (word, rank)
-- select food as word,
-- count(*) as rank
-- from food
-- group by food;
insert into foodfix (word, rank)
select food as word,
count(*) as rank
from food
group by food;
drop trigger if exists food_foodfix_insert;
create trigger food_foodfix_insert AFTER
insert on food for EACH row
@@ -125,15 +126,15 @@ end;
-- Spellfix search example
with search_results as (
select word, rank
select word, score, f.rowid, f.*
from foodfix
where word MATCH 'B'
limit 1
inner join food f on f.food == word
where word match 'B'
)
select f.*, s.rank
from search_results s
inner join food f on s.word = f.food
order by f.date desc;
select rowid, food, score, date, description, amount, per100, energy
from search_results
group by food
order by score asc, date desc
create index dailyIdx on food(strftime('%Y-%m-%d', date));
create index weeklyIdx on food(strftime('%Y-%W', date));