Skip to content

Commit 33ae3f9

Browse files
committed
fix(search): built-in tag/property are excluded from semantic search
1 parent 3afb112 commit 33ae3f9

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

src/main/frontend/worker/embedding.cljs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,13 @@
4848
[repo]
4949
(get-in @*vector-search-state [:repo->index-info repo :indexing?]))
5050

51-
(defn- hidden-entity?
52-
[entity]
53-
(or (ldb/hidden? entity)
54-
(let [page (:block/page entity)]
55-
(and (ldb/hidden? page)
56-
(not= (:block/title page) common-config/quick-add-page-name)))))
57-
5851
(defn- stale-block-filter-preds
5952
"When `reset?`, ignore :logseq.property.embedding/hnsw-label-updated-at in block"
6053
[reset?]
6154
(let [preds (cond->> (list (fn [b]
62-
(let [db-ident (:db/ident b)
63-
title (:block/title b)]
64-
(and (or (nil? db-ident)
65-
(not (string/starts-with? (namespace db-ident) "logseq.")))
66-
(not (string/blank? title))
67-
(not (hidden-entity? b))
55+
(let [title (:block/title b)]
56+
(and (not (string/blank? title))
57+
(not (ldb/hidden? b))
6858
(nil? (:logseq.property/view-for b))
6959
(not (keyword-identical?
7060
:logseq.property/description
@@ -252,7 +242,9 @@
252242
(keep (fn [[distance label]]
253243
;; (prn :debug :semantic-search-result
254244
;; :block (:block/title (d/entity @conn label))
255-
;; :distance distance)
245+
;; :page? (ldb/page? (d/entity @conn label))
246+
;; :distance distance
247+
;; :label label)
256248
(when-not (or (js/isNaN distance) (>= distance 0.6)
257249
(> label 2147483647))
258250
(when-let [block (d/entity @conn label)]

src/main/frontend/worker/search.cljs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,12 @@ DROP TRIGGER IF EXISTS blocks_au;
192192
:rowMode "array"}))
193193
blocks (bean/->clj result)]
194194
(keep (fn [block]
195-
(let [[id page title rank snippet] (if enable-snippet?
196-
(update block 4 get-snippet-result)
197-
block)]
195+
(let [[id page title _rank snippet] (if enable-snippet?
196+
(update block 4 get-snippet-result)
197+
block)]
198198
(when title
199199
{:id id
200-
:keyword-score (+ (fuzzy/score q title) (js/Math.abs rank))
200+
:keyword-score (fuzzy/score q title)
201201
:page page
202202
:title title
203203
:snippet snippet}))) blocks))

0 commit comments

Comments
 (0)