Browse Source

enhancement: NKFC normalize searching queries

Junyi Du 4 years ago
parent
commit
0fd86fd691

+ 2 - 2
src/main/frontend/components/search.cljs

@@ -35,8 +35,8 @@
     content
     (when (and content q)
       (let [q-words (string/split q #" ")
-            lc-content (string/lower-case content)
-            lc-q (string/lower-case q)]
+            lc-content (util/search-normalize content)
+            lc-q (util/search-normalize q)]
         (if (and (string/includes? lc-content lc-q)
                  (not (util/safe-re-find #" " q)))
           (let [i (string/index-of lc-content lc-q)

+ 2 - 2
src/main/frontend/search.cljs

@@ -89,7 +89,7 @@
 (defn block-search
   [repo q option]
   (when-let [engine (get-engine repo)]
-    (let [q (string/lower-case q)
+    (let [q (util/search-normalize q)
           q (if (util/electron?) q (escape-str q))]
       (when-not (string/blank? q)
         (protocol/query engine q option)))))
@@ -117,7 +117,7 @@
    (page-search q 10))
   ([q limit]
    (when-let [repo (state/get-current-repo)]
-     (let [q (string/lower-case q)
+     (let [q (util/search-normalize q)
            q (clean-str q)]
        (when-not (string/blank? q)
          (let [indice (or (get-in @indices [repo :pages])

+ 1 - 1
src/main/frontend/search/db.cljs

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