You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by ZmeiGorynych January 21, 2025
Hi,
I have an instance of MetadataFilters and a List[BaseNode] and would like to select those nodes from that list that fit the filter. Is there already a function to do that? I'd think there would be a def MetadataFilters.matches(node: BaseNode) -> bool method, but haven't been able to find anything like that.
Reluctant to write my own as it'd have to support arbitrarily deep nested filters, etc.
Dosubot thinks there is no ready-made function for that and I have to write my own. Shall I contribute a method to the MetadataFilters class that does it?
The text was updated successfully, but these errors were encountered:
I found a similar discussion titled "Directly evaluating a MetadataFilters instance on a BaseNode instance" which is still open. The discussion revolves around the need for a method to filter a list of BaseNode instances using an instance of MetadataFilters. A bot response in the discussion suggests that there is a utility function named filter_nodes that can accomplish this task by iterating through the nodes and checking if their metadata matches the filters defined in MetadataFilters, returning the matching nodes [1].
The MetadataFilters class itself supports nested AND and OR filters of arbitrary depth, as demonstrated by test cases like test_milvus_filter_with_nested_filters[1]. However, the filter_nodes utility function's implementation details and its ability to handle such nested filters are not clearly documented in the available information. If the current implementation does not meet your needs, you might consider extending it or contributing a method to the MetadataFilters class that can evaluate filters directly on BaseNode instances.
Discussed in #17574
Originally posted by ZmeiGorynych January 21, 2025
Hi,
I have an instance of
MetadataFilters
and aList[BaseNode]
and would like to select those nodes from that list that fit the filter. Is there already a function to do that? I'd think there would be adef MetadataFilters.matches(node: BaseNode) -> bool
method, but haven't been able to find anything like that.Reluctant to write my own as it'd have to support arbitrarily deep nested filters, etc.
Dosubot thinks there is no ready-made function for that and I have to write my own. Shall I contribute a method to the MetadataFilters class that does it?
The text was updated successfully, but these errors were encountered: