enhance: index normalized text only (case-insensitive)

pull/3930/head
Junyi Du 2022-01-15 04:30:28 +08:00 committed by Tienson Qin
parent 9a4b252bb1
commit 3afde150ce
3 changed files with 8 additions and 5 deletions

View File

@ -10,6 +10,7 @@
[frontend.mobile.util :as mobile-util] [frontend.mobile.util :as mobile-util]
[frontend.config :as config] [frontend.config :as config]
[frontend.db :as db] [frontend.db :as db]
[frontend.db.model :as db-model]
[frontend.extensions.zotero :as zotero] [frontend.extensions.zotero :as zotero]
[frontend.handler.editor :as editor-handler :refer [get-state]] [frontend.handler.editor :as editor-handler :refer [get-state]]
[frontend.handler.editor.lifecycle :as lifecycle] [frontend.handler.editor.lifecycle :as lifecycle]
@ -164,11 +165,12 @@
{:on-chosen chosen-handler {:on-chosen chosen-handler
:on-enter non-exist-block-handler :on-enter non-exist-block-handler
:empty-div [:div.text-gray-500.pl-4.pr-4 "Search for a block"] :empty-div [:div.text-gray-500.pl-4.pr-4 "Search for a block"]
:item-render (fn [{:block/keys [content page uuid]}] :item-render (fn [{:block/keys [page uuid]}] ;; content returned from search engine is normalized
(let [page (or (:block/original-name page) (let [page (or (:block/original-name page)
(:block/name page)) (:block/name page))
repo (state/sub :git/current-repo) repo (state/sub :git/current-repo)
format (db/get-page-format page)] format (db/get-page-format page)
content (:block/content (db-model/query-block-by-uuid uuid))]
[:.py-2 (search/block-search-result-item repo uuid format content q :block)])) [:.py-2 (search/block-search-result-item repo uuid format content q :block)]))
:class "black"})))) :class "black"}))))

View File

@ -198,10 +198,11 @@
(search-result-item "File" (highlight-exact-query data search-q)) (search-result-item "File" (highlight-exact-query data search-q))
:block :block
(let [{:block/keys [page content uuid]} data (let [{:block/keys [page uuid]} data ;; content here is normalized
page (util/get-page-original-name page) page (util/get-page-original-name page)
repo (state/sub :git/current-repo) repo (state/sub :git/current-repo)
format (db/get-page-format page)] format (db/get-page-format page)
content (:block/content (model/query-block-by-uuid uuid))]
[:span {:data-block-ref uuid} [:span {:data-block-ref uuid}
(search-result-item "Block" (search-result-item "Block"
(block-search-result-item repo uuid format content search-q search-mode))]) (block-search-result-item repo uuid format content search-q search-mode))])

View File

@ -22,7 +22,7 @@
(when-let [result (->> (text/remove-level-spaces content format) (when-let [result (->> (text/remove-level-spaces content format)
(drawer/remove-logbook) (drawer/remove-logbook)
(property/remove-built-in-properties format) (property/remove-built-in-properties format)
(util/search-normalize-content))] (util/search-normalize))]
{:id (:db/id block) {:id (:db/id block)
:uuid (str uuid) :uuid (str uuid)
:page page :page page