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
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.
publicclassKnowledgeChunk{[BsonId(IdGenerator=typeof(StringObjectIdGenerator))][BsonRepresentation(BsonType.ObjectId)][VectorStoreRecordKey]publicrequiredstringId{get;set;}[BsonElement("chunkNumber")][VectorStoreRecordData(IsFilterable=true)]publicintChunkNumber{get;set;}[BsonElement("text")][VectorStoreRecordData]publicrequiredstringText{get;set;}[BsonElement("textEmbedding")][VectorStoreRecordVector(1536,DistanceFunction.CosineSimilarity)]publicReadOnlyMemory<float>?TextEmbedding{get;set;}[BsonElement("metadata")]// [VectorStoreRecordData] // Uncommenting this throws an errorpublicrequiredKnowledgeChunkMetadataMetadata{get;set;}}[BsonIgnoreExtraElements]publicclassKnowledgeChunkMetadata{[BsonElement("source")][VectorStoreRecordData(IsFilterable=true)]publicrequiredstringSource{get;set;}[BsonElement("targetId")][VectorStoreRecordData(IsFilterable=true)]publicrequiredstringTargetId{get;set;}}
Problem
Error When Marking Nested Properties as Filterable:
Uncommenting [VectorStoreRecordData] on the Metadata property throws an exception due to unsupported property types:
System.ArgumentException: Data properties must be one of the supported types...
Type of the property 'Metadata' is Gravity9.Service.Agent.Application.Plugins.KnowledgeDb.KnowledgeChunkMetadata.
No Way to Filter Nested Fields:
There’s no clear method to filter on nested fields like Metadata.Source using the VectorSearchFilter API.
Limitation in Supported Data Types:
Reviewing MongoDBConstants.SupportedDataTypes suggests only primitive data types are filterable, blocking nested object filtering.
Flatten or Path-Based Filtering:
Implement path-based filtering similar to MongoDB’s dot notation (metadata.source), or automatically flatten nested objects for filtering.
Questions
Are there any plans to support filtering on nested sub-documents in MongoDBVectorStoreRecordCollection?
If not currently planned, would the team be open to accepting a community contribution to add this feature?
Thank you for considering this request!
Environment:
Library: SemanticKernel
Storage: MongoDB VectorStore
Language: C# (.NET 8.0)
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:
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: