From 11748e3be80e92dc28dafe8533432f6b4cf307b4 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Sun, 9 Jul 2023 14:35:47 +0200 Subject: [PATCH] provide .ejsl output; + sql scripts for preparing text search --- config.yaml | 15 +++++++++++++++ layouts/_default/baseof.html | 3 +++ sql/load.sql | 8 +++++--- sql/tables.sql | 4 ++-- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/config.yaml b/config.yaml index 90948a0..63a1ed7 100644 --- a/config.yaml +++ b/config.yaml @@ -21,3 +21,18 @@ related: weight: 100 threshold: 80 toLower: true + +# non-standard: escaped JSON lines +# with \\n and \\t for import to PostgreSQL jsonb column +mediaTypes: + x-text/ejsonl: + suffixes: + - ejsl + +outputFormats: + ejsl: + baseName: index + isPlainText: true + mediaType: x-text/ejsonl + + diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 15caaf0..816df8b 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -12,6 +12,9 @@ {{ hugo.Generator }} {{ $main := resources.Get "sass/main.scss" | toCSS | minify -}} + {{ with .OutputFormats.Get "rss" -}} + {{ printf `` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }} + {{ end -}} {{ block "config" . }}{{ end }} diff --git a/sql/load.sql b/sql/load.sql index 925385f..0d7b050 100644 --- a/sql/load.sql +++ b/sql/load.sql @@ -7,11 +7,13 @@ delete from hugo_input; 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 ... +-- TODO: +-- use cross join lateral jsonb_populate_recordset(null::hugo_text, data) +-- on conflict update ... +-- fill more columns -- sample query: --- select to_tsquery('german', 'prolog') as q \gset +-- select websearch_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; diff --git a/sql/tables.sql b/sql/tables.sql index 8567d99..10a7dad 100644 --- a/sql/tables.sql +++ b/sql/tables.sql @@ -8,9 +8,9 @@ create table hugo_text ( title text, content text, title_tsv tsvector generated always as - (to_tsvector('german', coalesce(title, ''))) stored, + (to_tsvector('german', title)) stored, content_tsv tsvector generated always as - (to_tsvector('german', coalesce(content, ''))) stored, + (to_tsvector('german', content)) stored, primary key (site, url) );