Skip to content

重制全局搜索 #4573

Closed
Closed
@88250

Description

@88250
Member

之前在 #3591 中开始尝试 fts5,后来在 #3708 移除了。

现在继续尝试,主要解决中文分词问题。

特别鸣谢链滴社区的一位老铁,他贡献的 C 代码帮助我们实现了 SQLite FTS5 中文单字分词 https://ld246.com/article/1641042386027

Activity

self-assigned this
on Apr 11, 2022
changed the title [-]新增 blocks_fts 虚拟表用于全文检索[/-] [+]新增 `blocks_fts` 虚拟表用于全文检索[/+] on Apr 11, 2022
added this to the 2.0.0 milestone on Apr 11, 2022
changed the title [-]新增 `blocks_fts` 虚拟表用于全文检索[/-] [+]重制实现全局搜索[/+] on Apr 11, 2022
changed the title [-]重制实现全局搜索[/-] [+]重制全局搜索[/+] on Apr 12, 2022
JCJC01

JCJC01 commented on Apr 12, 2022

@JCJC01

搜索后的定位显示也请改进,
举个例子,在思源里建了一个很长的表格,列为产品号,行为其相关信息,但是通过搜索产品号的时候,搜索栏只显示了部分相关信息,具体信息需要准确定位到文本或表格才能查看完整
即在搜索栏的结果内无法通过点击定位到指定的产品号的位置。
谢谢

88250

88250 commented on Apr 12, 2022

@88250
MemberAuthor

@JCJC01 请关注 #3171

fanglypro

fanglypro commented on Apr 13, 2022

@fanglypro

ctrp+p的搜索很快,但块引搜索貌似还是有点慢,块引搜索部分现在是还没修改吗?

fanglypro

fanglypro commented on Apr 13, 2022

@fanglypro

还有一个问题:搜索时有 "-" 符号时,搜索结果为空,不知道是不是和这个重制有关:

image

可以看到当我在搜索框中写上"-"时,就搜索不到文档了

image

88250

88250 commented on Apr 13, 2022

@88250
MemberAuthor

@fanglypro 块引搜索没改,我们先在全局搜索上跑一段时间看看。- 是 FTS 的查询语法操作符 https://www.sqlite.org/fts5.html#full_text_query_syntax

Zuoqiu-Yingyi

Zuoqiu-Yingyi commented on Apr 20, 2022

@Zuoqiu-Yingyi
Contributor

@88250 D大, 2.0.0-beta1 版本中 搜索 dialog 面板块引/块嵌入搜索菜单 中的文件路径匹配的关键词都无法高亮了, 标签搜索用的搜索页文件人类可读路径匹配的关键词可以高亮

Dialog 搜索面板

image

悬浮搜索菜单

image

搜索标签页

image

88250

88250 commented on Apr 20, 2022

@88250
MemberAuthor

@Zuoqiu-Yingyi 感谢反馈,b2 修复。

Zuoqiu-Yingyi

Zuoqiu-Yingyi commented on Apr 20, 2022

@Zuoqiu-Yingyi
Contributor

@fanglypro 块引搜索没改,我们先在全局搜索上跑一段时间看看。- 是 FTS 的查询语法操作符 https://www.sqlite.org/fts5.html#full_text_query_syntax

经过测试, 目前好像不支持使用 FTS 查询指定字段功能查询除 content 以外字段
https://www.sqlite.org/fts5.html#fts5_column_filters, 希望能使用如下语法触发指定字段的查询, 比如想查询某个域名所有超链接, content 字段只能查询到锚文本

-- 查询 markdown 字段
markdown: bilibili
-- 查询 memo 与 markdown 字段
{memo markdown}: bilibili

我想到的一种实现方式: 不指定数据库字段时只查询 content 字段, 指定数据库字段时查询该字段

88250

88250 commented on Apr 20, 2022

@88250
MemberAuthor

@Zuoqiu-Yingyi 看下帮助文档 - 查询语法,里面有提到一些限制。

88250

88250 commented on Apr 20, 2022

@88250
MemberAuthor

另外,用自己写的完整 SQL 应该可以做到。

Zuoqiu-Yingyi

Zuoqiu-Yingyi commented on Apr 20, 2022

@Zuoqiu-Yingyi
Contributor

另外,用自己写的完整 SQL 应该可以做到。

看到了, 多了 12 张表❤

Zuoqiu-Yingyi

Zuoqiu-Yingyi commented on Apr 20, 2022

@Zuoqiu-Yingyi
Contributor

@88250 又发现了一个bug, v2.0.0-beta-2 全局搜索输入框置空后显示最近编辑文件的功能丢了:broken_heart:

88250

88250 commented on Apr 20, 2022

@88250
MemberAuthor

@Zuoqiu-Yingyi 收到,感谢反馈啊。

Zuoqiu-Yingyi

Zuoqiu-Yingyi commented on Apr 21, 2022

@Zuoqiu-Yingyi
Contributor

@88250 块引用/块嵌入搜索不支持标点符号了, 使用 " 包围也没法搜索到:broken_heart:

思源笔记-bug反馈-26

补充1: 貌似是因为光标后的 " 未被视为查询语句的一部分
``[["#js"` 光标在后引号前无法查询, 在后引号后可以查询
image

image

补充2: [["#" js[["#" AND js 都可以满足要求, 该问题可以忽略了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @88250@Zuoqiu-Yingyi@fanglypro@JCJC01

      Issue actions

        重制全局搜索 · Issue #4573 · siyuan-note/siyuan