-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: django
-
None
Context
We want to support pushing simple negated filters (e.g., ~Q(field=value)) into $lookup stages to improve performance. Currently we support simple filters.
Definition of done
- The system can push simple negated expressions like ~Q(field=value) into the $lookup.pipeline.
- Only expressions where the negated condition refers to a field from the joined document are considered.
Pitfalls
- Be careful not to push negations that involve fields from the outer (parent) document, as this could lead to incorrect results.
- Complex or nested negations must be excluded unless explicitly supported.
- Incorrectly pushing unsupported negations could silently produce wrong query results.
- Always ensure pushed filters behave identically to the non-pushed ones.