provide .ejsl output; + sql scripts for preparing text search

This commit is contained in:
Helmut Merz 2023-07-09 14:35:47 +02:00
parent 852495fdb0
commit 11748e3be8
4 changed files with 25 additions and 5 deletions

View file

@ -21,3 +21,18 @@ related:
weight: 100 weight: 100
threshold: 80 threshold: 80
toLower: true 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

View file

@ -12,6 +12,9 @@
{{ hugo.Generator }} {{ hugo.Generator }}
{{ $main := resources.Get "sass/main.scss" | toCSS | minify -}} {{ $main := resources.Get "sass/main.scss" | toCSS | minify -}}
<link rel="stylesheet" href="{{ $main.Permalink }}"> <link rel="stylesheet" href="{{ $main.Permalink }}">
{{ with .OutputFormats.Get "rss" -}}
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
{{ end -}}
{{ block "config" . }}{{ end }} {{ block "config" . }}{{ end }}
</head> </head>
<body> <body>

View file

@ -7,11 +7,13 @@ delete from hugo_input;
insert into hugo_text (site, url, title, content) insert into hugo_text (site, url, title, content)
select data ->> 'site', data ->> 'url', data ->> 'title', data ->> 'content' select data ->> 'site', data ->> 'url', data ->> 'title', data ->> 'content'
from hugo_input; from hugo_input;
-- TODO: fill more columns -- TODO:
-- TODO: on conflict update ... -- use cross join lateral jsonb_populate_recordset(null::hugo_text, data)
-- on conflict update ...
-- fill more columns
-- sample query: -- sample query:
-- select to_tsquery('german', 'prolog') as q \gset -- select websearch_to_tsquery('german', 'prolog') as q \gset
-- select url, title, -- select url, title,
-- ts_headline(content, :q, 'MaxFragments=3, MaxWords=6, MinWords=3') -- ts_headline(content, :q, 'MaxFragments=3, MaxWords=6, MinWords=3')
-- from hugo_text where :q @@ content_tsv; -- from hugo_text where :q @@ content_tsv;

View file

@ -8,9 +8,9 @@ create table hugo_text (
title text, title text,
content text, content text,
title_tsv tsvector generated always as title_tsv tsvector generated always as
(to_tsvector('german', coalesce(title, ''))) stored, (to_tsvector('german', title)) stored,
content_tsv tsvector generated always as content_tsv tsvector generated always as
(to_tsvector('german', coalesce(content, ''))) stored, (to_tsvector('german', content)) stored,
primary key (site, url) primary key (site, url)
); );