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

Add internal kernel API /api/block/getBlocksIndexes #10608

Closed
Misuzu2027 opened this issue Mar 14, 2024 · 3 comments
Closed

Add internal kernel API /api/block/getBlocksIndexes #10608

Misuzu2027 opened this issue Mar 14, 2024 · 3 comments
Assignees
Milestone

Comments

@Misuzu2027
Copy link

Misuzu2027 commented Mar 14, 2024

希望添加 批量获取块位置 接口

In what scenarios do you need this feature?

我正在开发一个基于文档搜索的插件,现在想要实现一个原文排序的功能,目前单纯通过 sql 无法获取块的具体位置。
现有接口 /api/block/getBlockIndex 可以获取单个块的位置,当需要一次性获取许多(比如100个)块位置的时候,接口的并发会导致软件卡顿,所以需要一个批量接口。

Describe the optimal solution

  • 接口入参建议:

    • {
          "ids": [
              "20240314100641-p551qlp",
              "20240314100649-j09n4rx"
          ]
      }
      
  • 接口响应建议:

    • // 直接使用 Map 结构, blockId 作为 key, index 作为值
      {
          "code": 0,
          "data": {
              "20240314100641-p551qlp": 1,
              "20240314100649-j09n4rx": 2
          },
          "msg": ""
      }
      
    • 如果传入的块 id 不存在或是文档块,可以跟 /api/block/getBlockIndex 接口一样,值为 0。

Describe the candidate solution

如果可以在 blocks 表中添加原文顺序 index 字段那就更好了(就不需要添加这个借口了),不过修改表结构,同时还要维护 index 字段想来也不太容易。

Other information

No response

@88250 88250 self-assigned this Mar 14, 2024
@88250 88250 added this to the 3.0.4 milestone Mar 15, 2024
@88250 88250 changed the title 希望添加 批量获取块位置 接口 Add internal kernel API /api/block/getBlocksIndexes Mar 15, 2024
@88250
Copy link
Member

88250 commented Mar 15, 2024

这里需要隐式保证传入的 ids 都是同一个文档的才行,因为实现上需要先加载 .sy 语法树。我们默认就用第一个 id 加载吧。

@Misuzu2027
Copy link
Author

Misuzu2027 commented Mar 18, 2024

@88250 D 大,我今天用测试版试了下这个接口,有些情况批量接口返回的索引与 /api/block/getBlockIndex 的值不一样。
不一致的地方有两个:

  • 批量查询的索引好像是从0开始,单个接口是从1开始的。
  • 批量查询接口,列表块中的段落块索引一直返回0;单个接口返回的是与列表块一样的值。
测试数据:
  • 下面这个是文档结构:
    • image
  • 批量查询接口的响应数据:
    • image
  • 单个查询索引接口中段落块的数据:
    • image

希望可以与获取单个索引接口的规则一致。

@88250
Copy link
Member

88250 commented Mar 18, 2024

收到,稍后调整。

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

2 participants