Skip to content

.Net: Bug: Qdrant Vector Store filtering with Nullable<bool>/bool? fails #11665

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

Open
TsengSR opened this issue Apr 21, 2025 · 0 comments
Open
Assignees
Labels
bug Something isn't working msft.ext.vectordata Related to Microsoft.Extensions.VectorData .NET Issue or Pull requests regarding .NET code

Comments

@TsengSR
Copy link

TsengSR commented Apr 21, 2025

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
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code triage labels Apr 21, 2025
@github-actions github-actions bot changed the title .NET: Bug: Quadrant Vector Store filtering with Nullable<bool>/bool? fails .Net: Bug: Quadrant Vector Store filtering with Nullable<bool>/bool? fails Apr 21, 2025
@TsengSR TsengSR changed the title .Net: Bug: Quadrant Vector Store filtering with Nullable<bool>/bool? fails .Net: Bug: Qdrant Vector Store filtering with Nullable<bool>/bool? fails Apr 21, 2025
@markwallace-microsoft markwallace-microsoft added msft.ext.vectordata Related to Microsoft.Extensions.VectorData bug Something isn't working and removed triage labels Apr 22, 2025
@westey-m westey-m assigned roji and unassigned westey-m Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working msft.ext.vectordata Related to Microsoft.Extensions.VectorData .NET Issue or Pull requests regarding .NET code
Projects
Status: Bug
Development

No branches or pull requests

4 participants