Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:sparkles: Semantic search using AI embeddings https://github.com/siyuan-note/siyuan/issues/17788

Daniel418a47a9597b
diff --git a/kernel/cli/cmd/search.go b/kernel/cli/cmd/search.go
index 7145fae054..10f0ef0c23 100644
--- a/kernel/cli/cmd/search.go
+++ b/kernel/cli/cmd/search.go
@@ -53,8 +53,16 @@ var searchCmd = &cobra.Command{
types := stringSliceToMap(typeFlags)
subTypes := stringSliceToMap(subtypeFlags)
- blocks, matchedBlockCount, matchedRootCount, pageCount, docMode :=
- model.FullTextSearchBlock(query, notebooks, paths, types, subTypes, method, orderBy, groupBy, page, pageSize)
+ var docMode bool
+ var blocks []*model.Block
+ var matchedBlockCount, matchedRootCount, pageCount int
+ if method == 4 {
+ blocks, matchedBlockCount, matchedRootCount, pageCount =
+ model.SemanticSearchBlock(query, notebooks, paths, types, subTypes, page, pageSize)
+ } else {
+ blocks, matchedBlockCount, matchedRootCount, pageCount, docMode =
+ model.FullTextSearchBlock(query, notebooks, paths, types, subTypes, method, orderBy, groupBy, page, pageSize)
+ }
switch outputFormat {
case "json":
@@ -125,7 +133,7 @@ func init() {
searchCmd.Flags().StringArray("path", nil, "path prefix filter (repeatable)")
searchCmd.Flags().StringArrayP("type", "t", nil, "block type filter, repeatable (document heading paragraph list listItem codeBlock mathBlock table blockquote superBlock htmlBlock embedBlock databaseBlock audioBlock videoBlock iframeBlock widgetBlock callout)")
searchCmd.Flags().StringArray("subtype", nil, "block subtype filter, repeatable (o u t)")
- searchCmd.Flags().IntP("method", "m", 0, "search method: 0=keyword 1=query-syntax 2=sql 3=regex")
+ searchCmd.Flags().IntP("method", "m", 0, "search method: 0=keyword 1=query-syntax 2=sql 3=regex 4=fuzzy")
searchCmd.Flags().IntP("order-by", "o", 0, "order: 0=type 1=created-asc 2=created-desc 3=updated-asc 4=updated-desc 5=content 6=relevance-asc 7=relevance-desc")
searchCmd.Flags().IntP("page", "p", 1, "page number")
searchCmd.Flags().IntP("page-size", "s", 32, "results per page")