Skip to content

Conversation

GGrassia
Copy link

@GGrassia GGrassia commented Oct 9, 2025

Description

Added custom metadata on chunks and nodes with possibility of filtering in query to narrow the field of the knowledge base to pull context from, to both enhance precision and speed.
Metadata are stored as a json string and indexe
Metadata_filter class supports operators for AND, NOT, OR clauses and nested metadata_filter classes for chained or hierarchical filters, [ ... ] arrays for multiple possible values for a single metadata key.
I will gladly cooperate for bugfixing and further development.

Related Issues

As requested and discussed into question/issue #1985

Changes Made

  • Added Pydantic metadata_filter class
  • Added metadata_filter class to all base implementations of query for chunks
  • Added metadata management in chunk writing for Postgres
  • Added metadata as properties on nodes for Neo4j
  • Added metadata filter building for postgres_impl and updated queries for chunks, entities and relations to allow filtering

Checklist

  • Changes tested locally - (fully working in prod for our specific solution!)
  • Code reviewed
  • Documentation updated (if necessary)
  • Unit tests added (if applicable)

Additional Notes

[Add any additional notes or context for the reviewer(s).]

Giulio Grassia and others added 15 commits September 25, 2025 15:37
…querying

- Implement custom metadata insertion as node properties during file upload.
- Add basic metadata filtering functionality to query API

--NOTE: While the base.py file has been modified, the base implementation is incomplete and untested. Only Neo4j database has been properly implemented and tested.

WIP: Query API is temporarily mocked for debugging. Full implementation with complex AND/OR filtering capabilities is in development.

# Conflicts:
#	lightrag/base.py
#	lightrag/lightrag.py
#	lightrag/operate.py
Added metadata filter dataclass for serializing and deserializing
complex filter to json dict, added node filtering based on metadata
Added functioning (needs testing) metadata filtering on chunks for
query. Fully implemented only on Postgres with pgvector and Neo4j
Added metadata management for chunks in querying for all vdb, ONLY
posgres with pgvector has been fully implemented
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant