fix: search indexing should handle many properties

also fixed same case for similar readable-properties
part of LOG-2921
pull/10544/head
Gabriel Horner 2023-11-22 11:28:20 -05:00
parent 265fccd6bc
commit 6c618ffae1
3 changed files with 33 additions and 34 deletions

View File

@ -42,13 +42,17 @@
[properties]
(->> properties
(map (fn [[k v]]
(let [prop-ent (db-utils/entity [:block/uuid k])]
(let [prop-ent (db-utils/entity [:block/uuid k])
readable-property-val
#(if (seq (get-in prop-ent [:block/schema :values])) ; closed values
(when-let [block (db-utils/entity [:block/uuid %])]
(or (:block/original-name block)
(get-in block [:block/schema :value])))
%)]
[(-> prop-ent :block/name keyword)
(if (seq (get-in prop-ent [:block/schema :values])) ; closed values
(when-let [block (db-utils/entity [:block/uuid v])]
(or (:block/original-name block)
(get-in block [:block/schema :value])))
v)])))
(if (set? v)
(set (map readable-property-val v))
(readable-property-val v))])))
(into {})))
(defn property-value-when-closed

View File

@ -111,14 +111,6 @@
(when-let [engine (get-engine repo)]
(protocol/transact-blocks! engine data)))
(defn- transact-pages!
"Transact pages to search engine
:pages-to-remove-set the set of pages to remove (not include those to update)
:pages-to-add the page entities to add"
[repo data]
(when-let [engine (get-engine repo)]
(protocol/transact-pages! engine data)))
(defn exact-matched?
"Check if two strings points toward same search result"
[q match]

View File

@ -29,29 +29,32 @@
(->> properties
(map
(fn [[k v]]
(let [value (if (uuid? v)
(let [e (db/entity [:block/uuid v])
value (or
;; closed value
(db-pu/property-value-when-closed e)
;; page
(:block/original-name e)
;; block generated by template
(and
(get-in e [:block/metadata :created-from-template])
(:block/content e))
;; first child
(let [parent-id (:db/id e)]
(:block/content (model/get-by-parent-&-left (db/get-db) parent-id parent-id))))]
value)
v)]
(when (and (not (string/blank? value))
(not (uuid? value)))
(let [values
(->> (if (set? v) v #{v})
(map (fn [val]
(if (uuid? val)
(let [e (db/entity [:block/uuid val])
value (or
;; closed value
(db-pu/property-value-when-closed e)
;; page
(:block/original-name e)
;; block generated by template
(and
(get-in e [:block/metadata :created-from-template])
(:block/content e))
;; first child
(let [parent-id (:db/id e)]
(:block/content (model/get-by-parent-&-left (db/get-db) parent-id parent-id))))]
value)
val)))
(remove string/blank?))]
(when (seq values)
(str (:block/original-name (db/entity [:block/uuid k]))
": "
value)))))
(string/join "; " values))))))
(remove nil?)
(string/join "; ")))
(string/join ";; ")))
(defn block->index
"Convert a block to the index for searching"