mirror of
https://github.com/logseq/logseq.git
synced 2026-05-19 02:12:41 +00:00
fix(search): add alias support to search result mapping
This commit is contained in:
@@ -561,6 +561,7 @@ DROP TRIGGER IF EXISTS blocks_au;
|
||||
{:block/parent [:db/id :block/uuid :block/title :logseq.property/built-in?
|
||||
:logseq.property/hide? :logseq.property/deleted-at]}
|
||||
{:block/tags [:db/id :db/ident :block/title :logseq.property/icon]}
|
||||
{:block/alias [:block/uuid :block/title]}
|
||||
{:block/_alias [:block/uuid :block/title]}
|
||||
:logseq.property/icon
|
||||
:logseq.property.node/display-type
|
||||
|
||||
@@ -527,6 +527,35 @@
|
||||
:block/title "ai"}
|
||||
(:alias result))))))))
|
||||
|
||||
(deftest search-result-detects-alias-match-from-pulled-result-map
|
||||
(testing "pulled search result maps include aliases for alias-match detection"
|
||||
(let [page-id #uuid "00000000-0000-0000-0000-000000000238"
|
||||
alias-id #uuid "00000000-0000-0000-0000-000000000239"
|
||||
block-key :frontend.worker.search/block
|
||||
page {:db/id 1
|
||||
:block/uuid page-id
|
||||
:block/title "Artificial Intelligence"
|
||||
:block/alias [{:block/uuid alias-id
|
||||
:block/title "ai"}]}]
|
||||
(with-redefs [d/entity (fn [& _]
|
||||
(throw (js/Error. "search result block should come from pull map")))
|
||||
ldb/page? (fn [entity] (= (:db/id entity) (:db/id page)))
|
||||
ldb/built-in? (constantly false)
|
||||
ldb/hidden? (constantly false)]
|
||||
(let [result (#'search/search-result->block-result
|
||||
(atom :db)
|
||||
"ai"
|
||||
nil
|
||||
{:enable-snippet? false}
|
||||
{:id (str page-id)
|
||||
:page (str page-id)
|
||||
:title "Artificial Intelligence ai"
|
||||
block-key page})]
|
||||
(is (= "Artificial Intelligence" (:block/title result)))
|
||||
(is (= {:block/uuid alias-id
|
||||
:block/title "ai"}
|
||||
(:alias result))))))))
|
||||
|
||||
(deftest upsert-blocks-batches-rows-into-single-sql-statement
|
||||
(let [calls (atom [])
|
||||
tx #js {:exec (fn [opts]
|
||||
|
||||
Reference in New Issue
Block a user