Pinned LangChain MongoDB self-query filter translation and typed metadata values
Parent: RAG Patterns · Published reference · snapshot 2026-10-31
↓ Facts as markdownall context files
Source-anchored research for Pinned LangChain MongoDB self-query filter translation and typed metadata values. Run status: COMPLETED.
These notes link each claim to its source. Some citations identify archived research reports that are no longer hosted on this site. A published reference means the content is available; it does not certify independent review or accuracy.Read the editorial policy and follow the sources before relying on a claim.
How it works
- Inference from the pinned implementation and Python parsing contract: malformed date strings can raise ValueError locally because the conversion helper does not catch parsing exceptions. Missing payload keys instead leave the dictionary unchanged; conversion is not comprehensive metadata validation. (medium confidence) [source]
Problems, failure modes and limitations
- At the pinned commit, visit_structured_query returns (structured_query.query, {}) when structured_query.filter is None. When a filter exists, it instead returns that query with {"pre_filter": filter.accept(translator)}. The translator itself adds no limit parameter. (medium confidence) [source]
- A March 5, 2024 issue reports an Atlas date operand rejection with langchain_mongodb 0.1.0 despite supplying a Python datetime. That historical server-side report does not establish failure of the pinned translator or prove that its conversion guarantees server acceptance. (low confidence) [source]
Comparisons and alternatives
- At the pinned commit, IN/NIN wrap every non-list comparison.value in a one-element list, mutating the Comparison object before conversion. Existing lists remain lists; a tuple is wrapped rather than expanded. (medium confidence) [source]
Facts and statements
- At commit d7d6913d1f31a146236154db18d6c222d2df492d, allowed comparators are EQ, NE, GT, GTE, LT, LTE, IN and NIN; their MongoDB spellings are $eq, $ne, $gt, $gte, $lt, $lte, $in and $nin. Logical operators are limited to AND and OR, mapped to $and and $or. _format_func calls the inherited validator before mapping; NOT is absent. (medium confidence) [source]
- At the pinned commit, visit_operation recursively visits its arguments and emits {"$and": [...]} or {"$or": [...]}. visit_comparison emits {attribute: {mapped_comparator: converted_value}}; nested logical trees retain their grouping. (medium confidence) [source]
- At the pinned commit, {"type":"date","date":"YYYY-MM-DD"} converts through datetime.datetime.strptime(value["date"], "%Y-%m-%d"). Python parsing defaults make the result midnight with no timezone information. (medium confidence) [source]
- At the pinned commit, a dictionary tagged type=datetime with a datetime key has Z replaced by +00:00 before datetime.datetime.fromisoformat. Explicit offsets survive parsing; strings without offsets produce naive datetime objects. The translator does not force every value to UTC. (medium confidence) [source]
- At the pinned commit, list conversion recursively processes elements, including nested lists and typed date/datetime dictionaries. Scalar IN/NIN date dictionaries therefore become lists containing Python datetime values. (medium confidence) [source]
- At the pinned commit, untagged dictionaries, other type tags, and tagged dictionaries missing their date/datetime payload key pass through unchanged. Ordinary dictionaries are not traversed. Strings, numbers, booleans and existing datetime objects receive no general type coercion. (medium confidence) [source]
- At the pinned commit, _similarity_search_with_score passes pre_filter to vector_search_stage for explicit vectors and to autoembedding_vector_search_stage for automatic embedding. pipelines.py imports both builders from pymongo_search_utils; the inspected translator does not implement BSON encoding or the downstream builder. (medium confidence) [source]
- The stable documentation source rendering lacks the datetime conversion helper and returns comparison.value directly after IN/NIN wrapping. The pinned source includes that helper. Treating the stable rendering as evidence for the pinned date behavior would therefore be incorrect. (medium confidence) [source]
Children
- No children recorded.