Fix: Add file_path field to full_docs storage#2171
Merged
danielaskdd merged 1 commit intoHKUDS:mainfrom Oct 5, 2025
Merged
Conversation
- Store file_path in full_docs storage - Update PostgreSQL implementation by map file_path to doc_name - Other storage implementation automatically handles the new field
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix: Add
file_pathfield tofull_docsstorageSummary
This PR adds a
file_pathfield to thefull_docsstorage layer, enabling better document tracking and citation capabilities. The implementation ensures compatibility across all storage backends (JSON, Redis, MongoDB, PostgreSQL) with special handling for PostgreSQL's existingdoc_namecolumn.Relalted Issue: #2167
Changes Made
1. Core Pipeline (
lightrag/lightrag.py)Modified
apipeline_enqueue_documentsfunction:Modified
ainsert_custom_chunksfunction:2. PostgreSQL Storage (
lightrag/kg/postgres_impl.py)SQL Template Updates:
upsert_doc_full: Mapsfile_path→doc_namefor INSERT/UPDATE operationsget_by_id_full_docs: Returnsdoc_nameasfile_pathfor consistencyget_by_ids_full_docs: Returnsdoc_nameasfile_pathfor batch operationsPGKVStorage.upsert() method:
3. Other Storage Implementations
No changes required for:
Technical Details
Field Mapping Strategy
PostgreSQL uses a bidirectional mapping approach:
file_path→doc_namedoc_name→file_pathThis preserves the existing PostgreSQL schema while maintaining a consistent application-layer interface.
Backward Compatibility
✅ Fully backward compatible:
file_pathwill return empty string ("")COALESCE(doc_name, '') as file_pathto handle NULL valuesImpact
doc_namecolumn)