diff --git a/src/main/frontend/components/search.cljs b/src/main/frontend/components/search.cljs index 299b18ab3d..cbf3a77128 100644 --- a/src/main/frontend/components/search.cljs +++ b/src/main/frontend/components/search.cljs @@ -243,7 +243,7 @@ search-q (state/sub :search/q) show-result? (boolean (seq search-result)) blocks-count (or (db/blocks-count) 0) - timeout (if (> blocks-count 2000) 300 100)] + timeout (if (> blocks-count 2000) 500 100)] (rum/with-context [[t] i18n/*tongue-context*] [:div#search.flex-1.flex [:div.inner diff --git a/src/main/frontend/search.cljs b/src/main/frontend/search.cljs index a0431aa9d8..e163f07d81 100644 --- a/src/main/frontend/search.cljs +++ b/src/main/frontend/search.cljs @@ -37,7 +37,9 @@ (bean/->js)) indice (fuse. blocks (clj->js {:keys ["uuid" "content"] - }))] + :shouldSort true + :minMatchCharLength 2 + :threshold 0.4}))] (swap! indices assoc-in [repo :blocks] indice) indice))) @@ -50,7 +52,10 @@ (bean/->js)) indice (fuse. pages (clj->js {:keys ["name"] - :threshold 0.4}))] + :shouldSort true + :minMatchCharLength 2 + :threshold 0.2 + }))] (swap! indices assoc-in [repo :pages] indice) indice))) @@ -153,11 +158,12 @@ result (bean/->clj result)] (->> (map - (fn [{:keys [item] :as block}] - (let [{:keys [content uuid]} item] - {:block/uuid uuid - :block/content content - :block/page (:block/page (db/entity [:block/uuid (medley/uuid (str uuid))]))})) + (fn [{:keys [item matches] :as block}] + (let [{:keys [content uuid]} item] + {:block/uuid uuid + :block/content content + :block/page (:block/page (db/entity [:block/uuid (medley/uuid (str uuid))])) + :search/matches matches})) result) (remove nil?))))))))))