Skip to content

Commit dfed617

Browse files
authored
.Net: Update CosmosNoSql to latest SDK and update FullTextScore syntax (#12578)
### Motivation and Context The FullTextScore syntax for CosmosNoSql changed after the feature went GA recently so we need to update to the latest SDK version and update the syntax. #12545 ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [ ] The code builds clean without any errors or warnings - [ ] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [ ] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄
1 parent 1403596 commit dfed617

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

dotnet/Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
<PackageVersion Include="YamlDotNet" Version="15.3.0" />
163163
<PackageVersion Include="Fluid.Core" Version="2.24.0" />
164164
<!-- Memory stores -->
165-
<PackageVersion Include="Microsoft.Azure.Cosmos" Version="3.48.0-preview.0" />
165+
<PackageVersion Include="Microsoft.Azure.Cosmos" Version="3.52.0" />
166166
<PackageVersion Include="Pgvector" Version="0.3.1" />
167167
<PackageVersion Include="sqlite-vec" Version="0.1.7-alpha.2.1" />
168168
<PackageVersion Include="NRedisStack" Version="1.0.0" />

dotnet/src/VectorData/CosmosNoSql/CosmosNoSqlCollectionQueryBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static QueryDefinition BuildSearchQuery<TRecord>(
5757

5858
// Passing keywords using a parameter is not yet supported for FullTextScore so doing some crude string sanitization in the mean time to frustrate script injection.
5959
var sanitizedKeywords = keywords is not null ? keywords.Select(x => x.Replace("\"", "")) : null;
60-
var formattedKeywords = sanitizedKeywords is not null ? $"[\"{string.Join("\", \"", sanitizedKeywords)}\"]" : null;
60+
var formattedKeywords = sanitizedKeywords is not null ? $"\"{string.Join("\", \"", sanitizedKeywords)}\"" : null;
6161
var fullTextScoreArgument = textPropertyName is not null && keywords is not null ? $"FullTextScore({tableVariableName}.{textPropertyName}, {formattedKeywords})" : null;
6262

6363
var rankingArgument = fullTextScoreArgument is null ? vectorDistanceArgument : $"RANK RRF({vectorDistanceArgument}, {fullTextScoreArgument})";

dotnet/test/VectorData/CosmosNoSql.UnitTests/CosmosNoSqlCollectionQueryBuilderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public void BuildSearchQueryWithHybridFieldsReturnsValidHybridQueryDefinition()
259259
Assert.Contains("SELECT x.id,x.TestProperty1,x.TestProperty2,x.TestProperty3,VectorDistance(x.TestProperty1, @vector) AS TestScore", queryText);
260260
Assert.Contains("FROM x", queryText);
261261
Assert.Contains("WHERE x.TestProperty2 = @cv0 AND ARRAY_CONTAINS(x.TestProperty3, @cv1)", queryText);
262-
Assert.Contains("ORDER BY RANK RRF(VectorDistance(x.TestProperty1, @vector), FullTextScore(x.TestProperty2, [\"hybrid\"]))", queryText);
262+
Assert.Contains("ORDER BY RANK RRF(VectorDistance(x.TestProperty1, @vector), FullTextScore(x.TestProperty2, \"hybrid\"))", queryText);
263263
Assert.Contains("OFFSET 5 LIMIT 10", queryText);
264264

265265
Assert.Equal("@vector", queryParameters[0].Name);

0 commit comments

Comments
 (0)