-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.Net: New Feature: MongoDB VectorStore - Allow for filters on nested sub-documents #10152
Comments
@roji could you consider this in the filtering work you have started. |
Will do, thanks @markwallace-microsoft. Note to self: consider exactly what this means in term of modeling and ORM mapping - I'm not sure if and how we support hierarchical models in the current abstraction (/cc @westey-m). Query-wise, if we do LINQ, then users can express accesses to JSON subdocuments via C# - this is nice and easy. But the provider must then be directly aware of the user's POCO, in order to correctly interpret the incoming expression tree and translate it to the Mongo querying language. |
Thank you for the update! It looks like there's ongoing work related to filtering functionality in general. Is there any timeline or estimate for when the next pre-release might include support for filtering based on subdocument values? In the meantime, I might need to explore some workarounds:
Appreciate any insights you can share! |
@zarusz this will definitely take a while, as a lot of design changes are required to make everything work here (I don't think we have a clear architecture in mind for this yet). I'd advise bypassing the abstraction and working directly with the driver for now. |
We currently do not support hierarchical models for any parts of the vector store stack, i.e. reading records, writing records, or creating collections. It is something we have wanted to address, but it is a significant piece of work, and we haven't had the resources yet. The work would including updating RecordDefinitions and how we derive them from the data models, plus updating validation and mappers for each connector to support this. |
Okay, that all sounds reasonable. Thanks for the fast response. Keep up the good work folks, this project is what the .NET community needs! |
name: MongoDB VectorStore - Support Filters on Nested Sub-Documents
about: Currently,
MongoDBVectorStoreRecordCollection
does not support filtering on nested sub-documents. I am requesting the ability to apply filters on nested fields within MongoDB documents during vector searches.Feature Request
When working with
MongoDBVectorStoreRecordCollection
, it’s not possible to apply filters on nested sub-documents. This limitation prevents filtering on fields within embedded objects.Example Scenario:
Consider the following MongoDB document:
And this corresponding MongoDB index:
The model in C# is defined as:
Problem
Error When Marking Nested Properties as Filterable:
Uncommenting
[VectorStoreRecordData]
on theMetadata
property throws an exception due to unsupported property types:No Way to Filter Nested Fields:
There’s no clear method to filter on nested fields like
Metadata.Source
using theVectorSearchFilter
API.Example attempt (fails):
Limitation in Supported Data Types:
Reviewing
MongoDBConstants.SupportedDataTypes
suggests only primitive data types are filterable, blocking nested object filtering.Proposed Solution
Enable filtering on nested sub-document fields (e.g.,
metadata.source
,metadata.targetId
).Implement path-based filtering similar to MongoDB’s dot notation (
metadata.source
), or automatically flatten nested objects for filtering.Questions
MongoDBVectorStoreRecordCollection
?Thank you for considering this request!
Environment:
Impact:
This enhancement would significantly improve filtering flexibility for complex document structures and unlock more advanced search capabilities.
The text was updated successfully, but these errors were encountered: