feat: Add page_number attribute to document segments and update related retrieval logic #13742
+39
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This feature was first introduced in #7749, but then reverted since it has a bug in #8211 . Since then, there are couple of issues asking to reintroduce the feature.
The problem with the original feature in #7749 is that, it did not consider the case that not all document has page number info, such as txt, md files. It also added the page number attribute along with the embedding, which is not the most natural way to store the page number.
In this pull request, the page number is added to Document Segment, which requires a change in database schema. The page number is retrieved as part of the meta data.
Resolves #8502
Resolves #11891
Screenshots
Checklist
Important
Please review the checklist below before submitting your pull request.
dev/reformat
(backend) andcd web && npx lint-staged
(frontend) to appease the lint gods