-- load.sql

delete from hugo_input;

\copy hugo_input (data) from 'public/index.ejsl'

insert into hugo_text (site, url, title, content)
  select data ->> 'site', data ->> 'url', data ->> 'title', data ->> 'content'
  from hugo_input;
-- TODO: fill more columns
-- TODO: on conflict update ...

-- sample query:
-- select to_tsquery('german', 'prolog') as q \gset
-- select url, title, 
--     ts_headline(content, :q, 'MaxFragments=3, MaxWords=6, MinWords=3')  
--   from hugo_text where :q @@ content_tsv;
