add log to debug search

This commit is contained in:
Tienson Qin
2026-04-16 03:09:14 +08:00
parent 989e70284d
commit 843f871dc6
2 changed files with 16 additions and 13 deletions

View File

@@ -73,7 +73,7 @@
Bump to force a rebuild when the index format changes."
1)
(def ^:private search-index-build-batch-size 200)
(def ^:private search-index-build-batch-size 1000)
(def ^:private search-index-build-time-budget-ms 8)
(def ^:private search-index-build-idle-diff-ms 1000)
(def ^:private search-index-build-pause-ms 300)
@@ -904,6 +904,7 @@
(keep #(d/entity db (:e %)))
(remove search/hidden-entity?)
(keep search/block->index))]
(prn :debug :build-search-indice :remaining (count remaining))
(when (seq indexed)
(search/upsert-blocks! search-db (bean/->js indexed)))
(p/let [_ (js/Promise. (fn [resolve] (js/setTimeout resolve 0)))]

View File

@@ -448,18 +448,20 @@ DROP TRIGGER IF EXISTS blocks_au;
"Build a block title indice from scratch.
Incremental page title indice is implemented in frontend.search.sync-search-indice!"
[repo db]
(let [blocks (->> (get-all-fuzzy-supported-blocks db)
(map block->index)
(bean/->js))
indice (fuse. blocks
(clj->js {:keys ["title"]
:shouldSort true
:tokenize true
:distance 1024
:threshold 0.5 ;; search for 50% match from the start
:minMatchCharLength 1}))]
(swap! fuzzy-search-indices assoc repo indice)
indice))
(prn :debug :build-fuzzy-search-indice :graph repo)
(time
(let [blocks (->> (get-all-fuzzy-supported-blocks db)
(map block->index)
(bean/->js))
indice (fuse. blocks
(clj->js {:keys ["title"]
:shouldSort true
:tokenize true
:distance 1024
:threshold 0.5 ;; search for 50% match from the start
:minMatchCharLength 1}))]
(swap! fuzzy-search-indices assoc repo indice)
indice)))
(defn fuzzy-search
"Return a list of blocks (pages && tagged blocks) that match the query. Takes the following