Skip to content

.Net: Bug: HybridSearchAsync keyword search fails for CosmosNoSqlCollection #12545

Open
@ChrisL-GU

Description

@ChrisL-GU

Describe the bug
Performing a HybridSearchAsync with keywords results in the error:

The second through last arguments of the 'FullTextScore' function must be literals of type string or object specifying the fuzzy search argument containing a 'term' property which is a string and a 'distance' property which is a number between 0 and 2 (inclusive).

To Reproduce
Steps to reproduce the behavior:

  1. Create a new CosmosNoSqlCollection:
var collection = new <string, MyModel>(
    database,
    container,
    new CosmosNoSqlCollectionOptions
    {
        PartitionKeyPropertyName = nameof(MyModel.Id)
    });
  1. Use the collection: collection.HybridSearchAsync(query.Vector, ["test keyword"], top: 5);
  2. See error included above.

Expected behavior
The search results back without error

Platform

  • Language: C#
  • Source: Microsoft.SemanticKernel.Connectors.CosmosNoSql, version: 1.57.0-preview
  • IDE: Rider
  • OS: Linux

Additional context
It seems the code in CosmosNoSqlCollectionQueryBuilder for BuildSearchQuery is generating the query to Cosmos like so:

SELECT TOP 10 * FROM c ORDER BY RANK RRF(VectorDistance(c.vector, [1,2,3]), FullTextScore(c.content, ["searchable", "text", "goes" ,"here"]))

When it should it actually generate, i.e. without the brackets [, ]:

SELECT TOP 10 * FROM c ORDER BY RANK RRF(VectorDistance(c.vector, [1,2,3]), FullTextScore(c.content, "searchable", "text", "goes" ,"here"))

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETIssue or Pull requests regarding .NET codebugSomething isn't workingtriage

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions