-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Closed
Labels
.NETIssue or Pull requests regarding .NET codeIssue or Pull requests regarding .NET codeBuildFeatures planned for next Build conferenceFeatures planned for next Build conferencebugSomething isn't workingSomething isn't workingmsft.ext.vectordataRelated to Microsoft.Extensions.VectorDataRelated to Microsoft.Extensions.VectorData
Description
Describe the bug
When the Filter predicate on VectorSearchOptions<T>
is a nullable, search fails with an exception.
activeOnly
is defined as bool? activeOnly = null
in the methods parameters. Since the if block already ensures its never null, I don't see any issue why that operation should fail.
Both activeOnly
and activeOnly.Value
result in the exception.
Only by changing the method declaration to bool activeOnly
or bool activeOnly = true
, read non-nullable, the query executes successfully.
Imho this is not an expected behaviour and should be fixed, as its a very common way to define predicates that way.
To Reproduce
Expression<Func<Project, bool>>? filter = null;
if (activeOnly is not null)
{
filter = project => project.IsActive == activeOnly;
}
VectorSearchOptions<Project> filterOptions = new()
{
Top = top,
IncludeTotalCount = true,
Filter = filter,
};
Throws:
Exception Details
System.NotSupportedException HResult=0x80131515 Message=Equality expression not supported by Qdrant Source=Microsoft.SemanticKernel.Connectors.Qdrant StackTrace: at Microsoft.SemanticKernel.Connectors.Qdrant.QdrantFilterTranslator.TranslateEqual(Expression left, Expression right, Boolean negated) at Microsoft.SemanticKernel.Connectors.Qdrant.QdrantFilterTranslator.Translate(Expression node) at Microsoft.SemanticKernel.Connectors.Qdrant.QdrantFilterTranslator.Translate(LambdaExpression lambdaExpression, IReadOnlyDictionary`2 storagePropertyNames) at Microsoft.SemanticKernel.Connectors.Qdrant.QdrantVectorStoreRecordCollection`1.d__32`1.MoveNext()
Expression<Func<Project, bool>>? filter = null;
if (activeOnly is not null)
{
filter = project => project.IsActive == activeOnly.Value;
}
VectorSearchOptions<Project> filterOptions = new()
{
Top = top,
IncludeTotalCount = true,
Filter = filter,
};
Expected behavior
Operation to succeed.
Platform
- Language: C#
- Source: Nuget
- Microsoft.SemanticKernel 1.47.0
- Microsoft.SemanticKernel.Connectors.Ollama 1.47.0-alpha
- Microsoft.SemanticKernel.Connectors.Qdrant 1.47.0-preview
- AI model: not applicable
- IDE: Visual Studio 2022
- OS: Windows 11, 24H2
Metadata
Metadata
Assignees
Labels
.NETIssue or Pull requests regarding .NET codeIssue or Pull requests regarding .NET codeBuildFeatures planned for next Build conferenceFeatures planned for next Build conferencebugSomething isn't workingSomething isn't workingmsft.ext.vectordataRelated to Microsoft.Extensions.VectorDataRelated to Microsoft.Extensions.VectorData
Type
Projects
Status
Sprint: Done