summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2023-12-14 16:55:50 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2023-12-14 16:55:50 +0100
commit59018336e7923353ade0552f20c09585c1d63df5 (patch)
tree9f31ff02657826a0f33ea9facec8fbcbdd81a899
parentc7ce0adf63375d2085f7636eee0e9c847dafa59f (diff)
downloadwww-andreasbaumann-cc-59018336e7923353ade0552f20c09585c1d63df5.tar.gz
www-andreasbaumann-cc-59018336e7923353ade0552f20c09585c1d63df5.tar.bz2
tested absurd-sql, couldnt make that one work
-rw-r--r--search/fts5/README23
1 files changed, 15 insertions, 8 deletions
diff --git a/search/fts5/README b/search/fts5/README
index f1c5006..681b425 100644
--- a/search/fts5/README
+++ b/search/fts5/README
@@ -15,7 +15,7 @@ cat <<EOF | sqlite3 posts.db
CREATE VIRTUAL TABLE posts USING fts5(uri,title,content);
EOF
-# https://jqlang.github.io/jq/manual/
+# create post SQL statements from JSON with JQ (https://jqlang.github.io/jq/manual/)
jq -j '.[] | "INSERT INTO posts(uri, title, content) VALUES (", ( [ .uri, .title, .content // empty ] | map(.|gsub("'"'"'";"`")|gsub("\n";" ")|@sh) | join(",")), ");\n"' \
posts.json > posts.sql
sqlite3 posts.db < posts.sql
@@ -24,8 +24,9 @@ cp posts.db ../../static/index/.
# some test queries
# https://www.legendu.net/misc/blog/hands-on-full-text-search-in-sqlite3/
# https://sqlite.org/fts5.html
-select uri from posts where posts MATCH 'OpenBSD' ORDER BY bm25(posts);
-select uri,highlight(posts, 1, '<b>', '</b>'),snippet(posts, 2, '<b>', '</b>', '...', 50) from posts where posts MATCH 'OpenBSD' ORDER BY bm25(posts) limit 5 offset 0;
+sqlite3 posts.db
+sqlite> select uri from posts where posts MATCH 'OpenBSD' ORDER BY bm25(posts);
+sqlite> select uri,highlight(posts, 1, '<b>', '</b>'),snippet(posts, 2, '<b>', '</b>', '...', 50) from posts where posts MATCH 'OpenBSD' ORDER BY bm25(posts) limit 5 offset 0;
# TODO: make a server-side search (search window and result page)
# this would mean we have to render the hugo and the ranklist part on the server?
@@ -59,20 +60,26 @@ In file included from /data/INSTALL/emscripten2/src/llvm-project/llvm/lib/Suppor
# hairy to build
# let's try a precompiled one
# https://verdicts.listen.dev/npm/sql.js-fts5
+# https://www.skypack.dev/view/sql.js-fts5
npm install sql.js-fts5
cp node_modules/sql.js-fts5/dist/sql-wasm.js ../../themes/new_theme/static/js/.
cp node_modules/sql.js-fts5/dist/sql-wasm.wasm ../../themes/new_theme/static/js/.
-# WASM is not read because of a charset-utf-8 added to application/wasm: https://github.com/gohugoio/hugo/issues/10734
-# hugo-0.120.1-charset.patch
+
+# WASM is not read with self-hosted hugo server because of a charset-utf-8 added
+# to application/wasm: https://github.com/gohugoio/hugo/issues/10734
+# => rebuild Hugo with hugo-0.120.1-charset.patch
+
+# https://jlongster.com/future-sql-web
+# https://github.com/jlongster/absurd-sql
+npm install absurd-sql
+cp node_modules/absurd-sql/src/sqlite-fs.js ../../themes/new_theme/static/js/.
+cp node_modules/absurd-sql/dist/indexeddb-backend.js ../../themes/new_theme/static/js/.
# TODO: add as sqlite.js to page with data (local sqlite fts search)
# https://blog.ouseful.info/2022/04/06/compiling-full-text-search-fts5-into-sqlite-wasm-build/
-# https://jlongster.com/future-sql-web
-# https://www.skypack.dev/view/sql.js-fts5
# https://github.com/phiresky/sql.js-httpvfs
# https://github.com/psanford/sqlite3vfshttp
# https://phiresky.github.io/blog/2021/hosting-sqlite-databases-on-github-pages/
-# https://github.com/jlongster/absurd-sql
# https://github.com/kbumsik/sqlite-wasm
sudo pacman -S typescript