From da9afec95d5ea2bc90e67453b53ceeb44ed2f7cc Mon Sep 17 00:00:00 2001 From: Norbert Czirjak Date: Mon, 21 Sep 2020 17:22:38 +0200 Subject: [PATCH] full text search improvements --- inst/dbfunctions.sql | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/inst/dbfunctions.sql b/inst/dbfunctions.sql index 88f176b..2ae39c4 100644 --- a/inst/dbfunctions.sql +++ b/inst/dbfunctions.sql @@ -1466,7 +1466,15 @@ CASE SELECT DISTINCT(fts.id), fts.property, - fts.raw, + CASE WHEN fts.property = 'BINARY' THEN + COALESCE( + (select mv.value from metadata_view as mv where mv.id = fts.id and mv.property = 'https://vocabs.acdh.oeaw.ac.at/schema#hasTitle' and mv.lang = _lang limit 1), + (select mv.value from metadata_view as mv where mv.id = fts.id and mv.property = 'https://vocabs.acdh.oeaw.ac.at/schema#hasTitle' and mv.lang = _lang2 limit 1), + (select mv.value from metadata_view as mv where mv.id = fts.id and mv.property = 'https://vocabs.acdh.oeaw.ac.at/schema#hasTitle' limit 1) + ) + ELSE + fts.raw + END as raw, CASE WHEN fts.property = 'BINARY' THEN ts_headline('english', REGEXP_REPLACE(fts.raw, '\s', ' ', 'g'), to_tsquery(_searchstr), 'MaxFragments=1,MaxWords=5,MinWords=2') ELSE ''