Skip to content

Commit d3857ed

Browse files
author
Minh Le
committed
fix merge conflict
2 parents c85b04a + 9dd94ec commit d3857ed

File tree

9 files changed

+3800
-14
lines changed

9 files changed

+3800
-14
lines changed

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22
<PropertyGroup>
3-
<ClientOfficialVersion>3.49.0</ClientOfficialVersion>
3+
<ClientOfficialVersion>3.49.1</ClientOfficialVersion>
44
<ClientPreviewVersion>3.50.0</ClientPreviewVersion>
5-
<ClientPreviewSuffixVersion>preview.0</ClientPreviewSuffixVersion>
5+
<ClientPreviewSuffixVersion>preview.1</ClientPreviewSuffixVersion>
66
<DirectVersion>3.38.0</DirectVersion>
77
<FaultInjectionVersion>1.0.0</FaultInjectionVersion>
88
<FaultInjectionSuffixVersion>beta.0</FaultInjectionSuffixVersion>

Microsoft.Azure.Cosmos/contracts/API_3.49.1.txt

Lines changed: 1705 additions & 0 deletions
Large diffs are not rendered by default.

Microsoft.Azure.Cosmos/contracts/API_3.50.0-preview.1.txt

Lines changed: 1874 additions & 0 deletions
Large diffs are not rendered by default.

Microsoft.Azure.Cosmos/src/Resource/Settings/FullTextPath.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class FullTextPath : IEquatable<FullTextPath>
4242
/// <summary>
4343
/// Gets or sets a string containing the language of the full text path.
4444
/// </summary>
45-
[JsonProperty(PropertyName = "language")]
45+
[JsonProperty(PropertyName = "language", NullValueHandling = NullValueHandling.Ignore)]
4646
public string Language { get; set; }
4747

4848
/// <summary>
@@ -62,11 +62,6 @@ public void ValidateFullTextPath()
6262
throw new ArgumentException("Argument {0} can't be null or empty.", nameof(this.Path));
6363
}
6464

65-
if (string.IsNullOrEmpty(this.Language))
66-
{
67-
throw new ArgumentException("Argument {0} can't be null or empty.", nameof(this.Language));
68-
}
69-
7065
if (this.Path[0] != '/')
7166
{
7267
throw new ArgumentException("The argument {0} is not a valid path.", this.Path);

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Fluent/ContainerSettingsTests.cs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,58 @@ await databaseForVectorEmbedding.DefineContainer(containerName, partitionKeyPath
806806
}
807807
}
808808

809+
[Ignore("Marking as ignore until emulator is updated")]
810+
[TestMethod]
811+
public async Task TestFullTextSearchPolicyOptionalLanguage()
812+
{
813+
string fullTextPath1 = "/fts1";
814+
Database databaseForFullTextSearch = await this.GetClient().CreateDatabaseAsync("fullTextSearchDB",
815+
cancellationToken: this.cancellationToken);
816+
817+
try
818+
{
819+
string containerName = "fullTextContainerTest";
820+
string partitionKeyPath = "/pk";
821+
822+
ContainerResponse containerResponse =
823+
await databaseForFullTextSearch.DefineContainer(containerName, partitionKeyPath)
824+
.WithFullTextPolicy(
825+
defaultLanguage: null,
826+
fullTextPaths: new Collection<FullTextPath>() { new FullTextPath()
827+
{
828+
Path = fullTextPath1
829+
}})
830+
.Attach()
831+
.WithIndexingPolicy()
832+
.WithFullTextIndex()
833+
.Path(fullTextPath1)
834+
.Attach()
835+
.Attach()
836+
.CreateAsync();
837+
838+
Assert.AreEqual(HttpStatusCode.Created, containerResponse.StatusCode);
839+
Assert.AreEqual(containerName, containerResponse.Resource.Id);
840+
Assert.AreEqual(partitionKeyPath, containerResponse.Resource.PartitionKey.Paths.First());
841+
ContainerProperties containerSettings = containerResponse.Resource;
842+
843+
// Validate FullText Paths.
844+
Assert.IsNotNull(containerSettings.FullTextPolicy);
845+
Assert.IsNull(containerSettings.FullTextPolicy.DefaultLanguage);
846+
Assert.IsNotNull(containerSettings.FullTextPolicy.FullTextPaths);
847+
Assert.AreEqual(1, containerSettings.FullTextPolicy.FullTextPaths.Count());
848+
Assert.IsNull(containerSettings.FullTextPolicy.FullTextPaths[0].Language);
849+
850+
// Validate Full Text Indexes.
851+
Assert.IsNotNull(containerSettings.IndexingPolicy.FullTextIndexes);
852+
Assert.AreEqual(1, containerSettings.IndexingPolicy.FullTextIndexes.Count());
853+
Assert.AreEqual(fullTextPath1, containerSettings.IndexingPolicy.FullTextIndexes[0].Path);
854+
}
855+
finally
856+
{
857+
await databaseForFullTextSearch.DeleteAsync();
858+
}
859+
}
860+
809861
[Ignore]
810862
[TestMethod]
811863
public async Task WithComputedProperties()

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetSDKAPI.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5415,7 +5415,7 @@
54155415
],
54165416
"MethodInfo": "System.String get_Path();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
54175417
},
5418-
"System.String Language[Newtonsoft.Json.JsonPropertyAttribute(PropertyName = \"language\")]": {
5418+
"System.String Language[Newtonsoft.Json.JsonPropertyAttribute(NullValueHandling = 1, PropertyName = \"language\")]": {
54195419
"Type": "Property",
54205420
"Attributes": [
54215421
"JsonPropertyAttribute"

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/CosmosContainerSettingsTests.cs

Lines changed: 95 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,7 @@ public void ValidateFullTextPathsAndIndexes()
292292
},
293293
new Cosmos.FullTextPath()
294294
{
295-
Path = fullTextPath3,
296-
Language = "en-US",
295+
Path = fullTextPath3
297296
},
298297
};
299298

@@ -333,13 +332,107 @@ public void ValidateFullTextPathsAndIndexes()
333332
Assert.AreEqual(fullTextPaths.Count, fullTextPolicy.FullTextPaths.Count());
334333
Assert.AreEqual(fullTextPaths[0].Path, fullTextPolicy.FullTextPaths[0].Path);
335334
Assert.AreEqual(fullTextPaths[0].Language, fullTextPolicy.FullTextPaths[0].Language);
335+
Assert.AreEqual(fullTextPaths[1].Path, fullTextPolicy.FullTextPaths[1].Path);
336+
Assert.AreEqual(fullTextPaths[1].Language, fullTextPolicy.FullTextPaths[1].Language);
337+
Assert.AreEqual(fullTextPaths[2].Path, fullTextPolicy.FullTextPaths[2].Path);
338+
Assert.AreEqual(fullTextPaths[2].Language, fullTextPolicy.FullTextPaths[2].Language);
336339

337340
CollectionAssert.AreEquivalent(fullTextPaths, fullTextPolicy.FullTextPaths.ToList());
338341

339342
Collection<Cosmos.FullTextIndexPath> fullTextIndexes = containerSettings.IndexingPolicy.FullTextIndexes;
340343
Assert.AreEqual("/fts1", fullTextIndexes[0].Path);
341344
Assert.AreEqual("/fts2", fullTextIndexes[1].Path);
342345
Assert.AreEqual("/fts3", fullTextIndexes[2].Path);
346+
Assert.AreEqual("en-US", fullTextPolicy.FullTextPaths[0].Language);
347+
Assert.AreEqual("en-US", fullTextPolicy.FullTextPaths[1].Language);
348+
Assert.IsNull(fullTextPolicy.FullTextPaths[2].Language);
349+
}
350+
351+
[TestMethod]
352+
public void ValidateFullTextLanguagesOptional()
353+
{
354+
string fullTextPath1 = "/fts1", fullTextPath2 = "/fts2";
355+
356+
Collection<FullTextPath> fullTextPaths = new Collection<FullTextPath>()
357+
{
358+
new Cosmos.FullTextPath()
359+
{
360+
Path = fullTextPath1
361+
},
362+
new Cosmos.FullTextPath()
363+
{
364+
Path = fullTextPath2,
365+
Language = "de-DE",
366+
}
367+
};
368+
369+
ContainerProperties containerSettings = new ContainerProperties(id: "TestContainer", partitionKeyPath: "/partitionKey")
370+
{
371+
FullTextPolicy = new()
372+
{
373+
FullTextPaths = fullTextPaths
374+
},
375+
IndexingPolicy = new Cosmos.IndexingPolicy()
376+
{
377+
FullTextIndexes = new()
378+
{
379+
new Cosmos.FullTextIndexPath()
380+
{
381+
Path = fullTextPath1,
382+
},
383+
new Cosmos.FullTextIndexPath()
384+
{
385+
Path = fullTextPath2,
386+
}
387+
},
388+
},
389+
};
390+
391+
Assert.IsNotNull(containerSettings.IndexingPolicy);
392+
Assert.IsNotNull(containerSettings.FullTextPolicy);
393+
Assert.IsNotNull(containerSettings.IndexingPolicy.FullTextIndexes);
394+
395+
Cosmos.FullTextPolicy fullTextPolicy = containerSettings.FullTextPolicy;
396+
Assert.IsNull(fullTextPolicy.DefaultLanguage);
397+
Assert.IsNotNull(fullTextPolicy.FullTextPaths);
398+
Assert.AreEqual(fullTextPaths.Count, fullTextPolicy.FullTextPaths.Count());
399+
Assert.AreEqual(fullTextPaths[0].Path, fullTextPolicy.FullTextPaths[0].Path);
400+
Assert.AreEqual(fullTextPaths[0].Language, fullTextPolicy.FullTextPaths[0].Language);
401+
Assert.AreEqual(fullTextPaths[1].Path, fullTextPolicy.FullTextPaths[1].Path);
402+
Assert.AreEqual(fullTextPaths[1].Language, fullTextPolicy.FullTextPaths[1].Language);
403+
404+
CollectionAssert.AreEquivalent(fullTextPaths, fullTextPolicy.FullTextPaths.ToList());
405+
406+
Collection<Cosmos.FullTextIndexPath> fullTextIndexes = containerSettings.IndexingPolicy.FullTextIndexes;
407+
Assert.AreEqual("/fts1", fullTextIndexes[0].Path);
408+
Assert.AreEqual("/fts2", fullTextIndexes[1].Path);
409+
Assert.IsNull(fullTextPolicy.FullTextPaths[0].Language);
410+
Assert.AreEqual("de-DE", fullTextPolicy.FullTextPaths[1].Language);
411+
412+
string serialized = this.Serialize(containerSettings);
413+
Assert.AreEqual(@"{""indexingPolicy"":{""automatic"":true,""indexingMode"":""Consistent"",""includedPaths"":[],""excludedPaths"":[],""compositeIndexes"":[],""spatialIndexes"":[],""vectorIndexes"":[],""fullTextIndexes"":[{""path"":""/fts1""},{""path"":""/fts2""}]},""fullTextPolicy"":{""fullTextPaths"":[{""path"":""/fts1""},{""path"":""/fts2"",""language"":""de-DE""}]},""id"":""TestContainer"",""partitionKey"":{""paths"":[""/partitionKey""],""kind"":""Hash""}}", serialized);
414+
}
415+
416+
private string Serialize(ContainerProperties containerProperties)
417+
{
418+
using (MemoryStream ms = new MemoryStream())
419+
{
420+
using (StreamWriter streamWriter = new StreamWriter(ms))
421+
{
422+
JsonSerializer jsonSerializer = new JsonSerializer();
423+
using (JsonWriter jsonWriter = new JsonTextWriter(streamWriter))
424+
{
425+
jsonSerializer.Serialize(jsonWriter, containerProperties);
426+
jsonWriter.Flush();
427+
428+
ms.Position = 0;
429+
using (StreamReader streamReader = new StreamReader(ms))
430+
{
431+
return streamReader.ReadToEnd();
432+
}
433+
}
434+
}
435+
}
343436
}
344437

345438
[TestMethod]

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Fluent/ContainerDefinitionForCreateTests.cs

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,7 @@ public async Task ValidateFullTextPolicyAndIndexUsingContainerBuilder()
357357
},
358358
new Cosmos.FullTextPath()
359359
{
360-
Path = fullTextPath3,
361-
Language = "en-US",
360+
Path = fullTextPath3
362361
},
363362
};
364363

@@ -412,7 +411,7 @@ public async Task ValidateFullTextPolicyAndIndexUsingContainerBuilder()
412411
&& fullTextPath2.Equals(settings.FullTextPolicy.FullTextPaths[1].Path)
413412
&& "en-US".Equals(settings.FullTextPolicy.FullTextPaths[1].Language)
414413
&& fullTextPath3.Equals(settings.FullTextPolicy.FullTextPaths[2].Path)
415-
&& "en-US".Equals(settings.FullTextPolicy.FullTextPaths[2].Language)
414+
&& (settings.FullTextPolicy.FullTextPaths[2].Language == null)
416415
&& fullTextPath1.Equals(settings.IndexingPolicy.FullTextIndexes[0].Path)
417416
&& fullTextPath2.Equals(settings.IndexingPolicy.FullTextIndexes[1].Path)
418417
&& fullTextPath3.Equals(settings.IndexingPolicy.FullTextIndexes[2].Path)),
@@ -421,6 +420,66 @@ public async Task ValidateFullTextPolicyAndIndexUsingContainerBuilder()
421420
It.IsAny<CancellationToken>()), Times.Once);
422421
}
423422

423+
[TestMethod]
424+
public async Task ValidateFullTextPolicyAndIndexUsingContainerBuilderOptionalLanguage()
425+
{
426+
string fullTextPath1 = "/fts1";
427+
428+
Collection<FullTextPath> fullTextPaths = new Collection<FullTextPath>()
429+
{
430+
new Cosmos.FullTextPath()
431+
{
432+
Path = fullTextPath1
433+
},
434+
};
435+
436+
Mock<ContainerResponse> mockContainerResponse = new Mock<ContainerResponse>();
437+
mockContainerResponse
438+
.Setup(x => x.StatusCode)
439+
.Returns(HttpStatusCode.Created);
440+
441+
Mock<Database> mockContainers = new Mock<Database>();
442+
Mock<CosmosClient> mockClient = new Mock<CosmosClient>();
443+
mockContainers.Setup(m => m.Client).Returns(mockClient.Object);
444+
mockContainers
445+
.Setup(c => c.CreateContainerAsync(
446+
It.IsAny<ContainerProperties>(),
447+
It.IsAny<int?>(),
448+
It.IsAny<RequestOptions>(),
449+
It.IsAny<CancellationToken>()))
450+
.ReturnsAsync(mockContainerResponse.Object);
451+
mockContainers
452+
.Setup(c => c.Id)
453+
.Returns(Guid.NewGuid().ToString());
454+
455+
ContainerBuilder containerFluentDefinitionForCreate = new ContainerBuilder(
456+
mockContainers.Object,
457+
containerName,
458+
partitionKey);
459+
460+
ContainerResponse response = await containerFluentDefinitionForCreate
461+
.WithFullTextPolicy(
462+
defaultLanguage: null,
463+
fullTextPaths: fullTextPaths)
464+
.Attach()
465+
.WithIndexingPolicy()
466+
.WithFullTextIndex()
467+
.Path(fullTextPath1)
468+
.Attach()
469+
.Attach()
470+
.CreateAsync();
471+
472+
Assert.AreEqual(HttpStatusCode.Created, response.StatusCode);
473+
mockContainers.Verify(c => c.CreateContainerAsync(
474+
It.Is<ContainerProperties>((settings) => settings.FullTextPolicy.FullTextPaths.Count == 1
475+
&& (settings.FullTextPolicy.DefaultLanguage == null)
476+
&& fullTextPath1.Equals(settings.FullTextPolicy.FullTextPaths[0].Path)
477+
&& (settings.FullTextPolicy.FullTextPaths[0].Language == null)),
478+
It.IsAny<int?>(),
479+
It.IsAny<RequestOptions>(),
480+
It.IsAny<CancellationToken>()), Times.Once);
481+
}
482+
424483
[TestMethod]
425484
public async Task ValidateVectorEmbeddingsAndIndexingPolicyUsingContainerBuilder()
426485
{

changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ Preview features are treated as a separate branch and will not be included in th
1515
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1616
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
1717

18+
### <a name="3.50.0-preview.1"/> [3.50.0-preview.1](https://www.nuget.org/packages/Microsoft.Azure.Cosmos/3.50.0-preview.1) - 2025-5-6
19+
20+
### <a name="3.49.1"/> [3.49.1](https://www.nuget.org/packages/Microsoft.Azure.Cosmos/3.49.1) - 2025-5-6
21+
22+
#### Fixed
23+
24+
- [5174](https://github.com/Azure/azure-cosmos-dotnet-v3/pull/5174) Query: Fixes default for the query plan optimization for Hybrid Search to be disabled
25+
1826
### <a name="3.50.0-preview.0"/> [3.50.0-preview.0](https://www.nuget.org/packages/Microsoft.Azure.Cosmos/3.50.0-preview.0) - 2025-4-17
1927

2028
#### Added

0 commit comments

Comments
 (0)