Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

嵌入块支持搜索 #7112

Closed
88250 opened this issue Jan 18, 2023 · 24 comments
Closed

嵌入块支持搜索 #7112

88250 opened this issue Jan 18, 2023 · 24 comments
Assignees
Milestone

Comments

@88250
Copy link
Member

88250 commented Jan 18, 2023

嵌入块 content 更新:

  1. 界面触发执行嵌入块搜索时更新
  2. 后台任务从数据库中获取 content 为空的嵌入块,执行根据 markdown 字段中的 SQL 语句获取 blocks,填充 content 字段

暂时不限制大量查询结果插入 content 字段,后续如果有性能问题再考虑限制。

界面调整:

  • 设置 - 搜索 - 类型 新增嵌入块
  • 搜索界面 - 类型过滤新增嵌入块

潜在的问题:

影响已有自定义 SQL 的嵌入块,需要用户自己调整 SQL,加上 type != 'query_embed' 的条件,否则查询结果会变少,因为搜索条目数限制下内置会跳过结果集中的嵌入块。

@88250 88250 self-assigned this Jan 18, 2023
@88250 88250 added this to the 2.7.1 milestone Jan 18, 2023
88250 added a commit that referenced this issue Jan 18, 2023
88250 added a commit that referenced this issue Jan 18, 2023
88250 added a commit that referenced this issue Jan 18, 2023
88250 added a commit that referenced this issue Jan 19, 2023
88250 added a commit that referenced this issue Jan 19, 2023
@88250 88250 closed this as completed Jan 19, 2023
88250 added a commit that referenced this issue Jan 19, 2023
@zxhd863943427
Copy link
Contributor

zxhd863943427 commented Jan 19, 2023

查询结果会变少,因为搜索条目数限制下内置会跳过结果集中的嵌入块。

能具体解释下吗?没太理解

@88250
Copy link
Member Author

88250 commented Jan 19, 2023

嵌入块支持搜索以后,原有 SQL 的返回结果可能会包含其他嵌入块,这里做了内置的嵌入块类型过滤,所以结果会变少。

@zxhd863943427
Copy link
Contributor

那么,假如一个嵌入块搜索的结果里,有一个结果里面包含了另一个嵌入块,那最终的显示效果是这个结果被跳过了,还是这个结果中的嵌入块不显示?

@88250
Copy link
Member Author

88250 commented Jan 19, 2023

搜索不到这个嵌入块。

@zxhd863943427
Copy link
Contributor

不不,我的意思是,嵌入块搜索的这个结果包含很多块,比如说搜索了一个标题,那会把标题下的块都显示出来。假如这个标题下有一个嵌入块,它会怎么处理?

@88250
Copy link
Member Author

88250 commented Jan 19, 2023

搜索不到的。

@zxhd863943427
Copy link
Contributor

也就是说,只要一个结果的全部块里里包含了一个嵌入块,那么这个结果就会搜索不到了?

@88250
Copy link
Member Author

88250 commented Jan 19, 2023

嵌入块查询结果中包含的嵌入块搜索不到。

@zxhd863943427
Copy link
Contributor

zxhd863943427 commented Jan 19, 2023

所以说,你的意思其实是,假如 嵌入块a 搜索的结果里包含了 嵌入块b ,那么,嵌入块a 可以正常地显示 嵌入块b ;但是打开搜索界面后进行搜索,我们无法搜索到在 嵌入块a 中的 嵌入块b,但是不被 嵌入块a 显示的、在原有位置的 嵌入块b ,以及 嵌入块a 中的其他内容依然能够搜索到?

@88250
Copy link
Member Author

88250 commented Jan 19, 2023

是的

@zxhd863943427
Copy link
Contributor

那么,目前的嵌入块的sql搜索是否会造成:

块a 被嵌入到另一个位置,形成 嵌入块b ,使用 嵌入块c 搜索 块a 时,会同时在结果里显示 块a 和 嵌入块b。然后又使用了一个 嵌入块d 来搜索 块a 的内容,会造成 嵌入块d 的结果中出现了 块a、 嵌入块b、嵌入块 c?

@88250
Copy link
Member Author

88250 commented Jan 19, 2023

这个情况一直是这样吧。

@zxhd863943427
Copy link
Contributor

以前嵌入块中的内容不会被搜索到啊,造成重复嵌入的最简单方法就是在一个标题下面插入这个标题本身的嵌入块。

现在重复嵌入好像更简单了。如我所说的话,那么其实 嵌入块c 中也会更新,把嵌入块 d 也加到结果里面,那么嵌入块 d 中的结果也会改变,变成更新后的 嵌入块c, 如此反复。就会造成类似下面的结果:

图片

由于嵌入块支持搜索了,那么目前只要两个嵌入块会搜索到同样的内容,它们就会进行互相嵌套,比以前更容易无意中产生了。

@88250
Copy link
Member Author

88250 commented Jan 19, 2023

这没法避免了,只能改 SQL 加入 type 排除嵌入块。

@zxhd863943427
Copy link
Contributor

我觉得这个才是更大的问题,以前的嵌入块都要受到影响,因为只要嵌入块搜索到同样的内容,就会造成重复嵌套。

有没有办法把嵌入块改成默认不搜索嵌入块?

@88250
Copy link
Member Author

88250 commented Jan 19, 2023

以前也有嵌套的需求的,这是个特性哦。

@zxhd863943427
Copy link
Contributor

zxhd863943427 commented Jan 19, 2023

嵌入块当然可以嵌套,但是以前的嵌入块嵌套要么是使用 嵌入块a 的块 id 来生成 嵌入块b ,要么是 容器块c 内包含了 嵌入块d,使用 嵌入块e 嵌入 容器块c 时把 嵌入块d 作为内容的一部分也嵌入了,跟目前可能造成的 ”嵌入块f 搜索到 嵌入块g 的内容,然后把 嵌入块g 作为结果展示“ 完全是两种东西。

因此,嵌入块改成 默认不搜索嵌入块 不会对之前的嵌入块嵌套造成影响,但是 默认搜索嵌入块 反而会。

@88250
Copy link
Member Author

88250 commented Jan 19, 2023

做不到默认不搜索的,因为用户的 SQL 无法解析,加不了默认排除类型。所以我在前面才会说是这个潜在的问题,需要用户自己调整 SQL。

@zxhd863943427
Copy link
Contributor

那目前有测试过这种重复嵌入的层数限制吗?还是就是跟以前一样,只到第五层?

@88250
Copy link
Member Author

88250 commented Jan 19, 2023

没有测过,这里没动过,我感觉应该是的。

@Zuoqiu-Yingyi
Copy link
Contributor

后台任务从数据库中获取 content 为空的嵌入块,执行根据 markdown 字段中的 SQL 语句获取 blocks,填充 markdown 字段

这是填充的应该是 content 字段吧

@88250
Copy link
Member Author

88250 commented Jan 20, 2023

@zxhd863943427
Copy link
Contributor

测试了一下,目前嵌入块在不添加 type != 'query_embed' 的情况下也搜索不到其他的嵌入块。

@88250
Copy link
Member Author

88250 commented Jan 20, 2023

默认会排除,不加条件的话缺点就是分页会变小。

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

No branches or pull requests

4 participants