fix(search): built-in tag/property are excluded from semantic search

This commit is contained in:
Tienson Qin
2025-11-06 21:25:18 +08:00
parent 3afb112b8f
commit 33ae3f9a0e
2 changed files with 10 additions and 18 deletions

View File

@@ -48,23 +48,13 @@
[repo]
(get-in @*vector-search-state [:repo->index-info repo :indexing?]))
(defn- hidden-entity?
[entity]
(or (ldb/hidden? entity)
(let [page (:block/page entity)]
(and (ldb/hidden? page)
(not= (:block/title page) common-config/quick-add-page-name)))))
(defn- stale-block-filter-preds
"When `reset?`, ignore :logseq.property.embedding/hnsw-label-updated-at in block"
[reset?]
(let [preds (cond->> (list (fn [b]
(let [db-ident (:db/ident b)
title (:block/title b)]
(and (or (nil? db-ident)
(not (string/starts-with? (namespace db-ident) "logseq.")))
(not (string/blank? title))
(not (hidden-entity? b))
(let [title (:block/title b)]
(and (not (string/blank? title))
(not (ldb/hidden? b))
(nil? (:logseq.property/view-for b))
(not (keyword-identical?
:logseq.property/description
@@ -252,7 +242,9 @@
(keep (fn [[distance label]]
;; (prn :debug :semantic-search-result
;; :block (:block/title (d/entity @conn label))
;; :distance distance)
;; :page? (ldb/page? (d/entity @conn label))
;; :distance distance
;; :label label)
(when-not (or (js/isNaN distance) (>= distance 0.6)
(> label 2147483647))
(when-let [block (d/entity @conn label)]

View File

@@ -192,12 +192,12 @@ DROP TRIGGER IF EXISTS blocks_au;
:rowMode "array"}))
blocks (bean/->clj result)]
(keep (fn [block]
(let [[id page title rank snippet] (if enable-snippet?
(update block 4 get-snippet-result)
block)]
(let [[id page title _rank snippet] (if enable-snippet?
(update block 4 get-snippet-result)
block)]
(when title
{:id id
:keyword-score (+ (fuzzy/score q title) (js/Math.abs rank))
:keyword-score (fuzzy/score q title)
:page page
:title title
:snippet snippet}))) blocks))