From 1aab0af219acea4b11d1826324fc2b86fe6f8f66 Mon Sep 17 00:00:00 2001 From: ShivangiReja Date: Mon, 4 Mar 2024 12:42:40 -0800 Subject: [PATCH 1/3] [Search] Add support for `sbyte` and `int16` types to FieldBuilder --- .../Azure.Search.Documents/CHANGELOG.md | 3 ++- .../Generated/Models/SearchFieldDataType.cs | 6 ----- .../src/Indexes/FieldBuilder.cs | 2 ++ .../src/Indexes/Models/SearchFieldDataType.cs | 12 ++++++++++ .../DocumentOperations/VectorSearchTests.cs | 2 ++ .../tests/FieldBuilderTests.cs | 14 ++++++++++- .../tests/Models/ReflectableModel.cs | 24 +++++++++++++++++++ .../tests/Models/ReflectableStructModel.cs | 24 +++++++++++++++++++ ...Sample07_VectorSearch_UsingFieldBuilder.cs | 2 ++ 9 files changed, 81 insertions(+), 8 deletions(-) diff --git a/sdk/search/Azure.Search.Documents/CHANGELOG.md b/sdk/search/Azure.Search.Documents/CHANGELOG.md index 46eae4cc33c8e..c447e8ef0652d 100644 --- a/sdk/search/Azure.Search.Documents/CHANGELOG.md +++ b/sdk/search/Azure.Search.Documents/CHANGELOG.md @@ -1,10 +1,11 @@ # Release History -## 11.6.0-beta.3 (2024-03-04) +## 11.6.0-beta.3 (2024-03-05) ### Features Added - Added the `VectorSearch.Compressions` property, which can be utilized to configure options specific to the compression method used during indexing or querying. - Added the `SearchField.IsStored`, `VectorSearchField.IsStored`, and `VectorSearchFieldAttribute.IsStored` property. It represent an immutable value indicating whether the field will be persisted separately on disk to be returned in a search result. This property is applicable only for vector fields. +- Added support for `sbyte` and `int16` to `SearchFieldDataType`. ## 11.6.0-beta.2 (2024-02-05) diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchFieldDataType.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchFieldDataType.cs index c06964b4e27d9..6f0cea7382fbe 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchFieldDataType.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchFieldDataType.cs @@ -34,12 +34,6 @@ public SearchFieldDataType(string value) private const string HalfValue = "Edm.Half"; private const string Int16Value = "Edm.Int16"; private const string SByteValue = "Edm.SByte"; - /// Indicates that a field contains a half-precision floating point number. This is only valid when used with Collection(Edm.Half). - public static SearchFieldDataType Half { get; } = new SearchFieldDataType(HalfValue); - /// Indicates that a field contains a 16-bit signed integer. This is only valid when used with Collection(Edm.Int16). - public static SearchFieldDataType Int16 { get; } = new SearchFieldDataType(Int16Value); - /// Indicates that a field contains a 8-bit signed integer. This is only valid when used with Collection(Edm.SByte). - public static SearchFieldDataType SByte { get; } = new SearchFieldDataType(SByteValue); /// Determines if two values are the same. public static bool operator ==(SearchFieldDataType left, SearchFieldDataType right) => left.Equals(right); /// Determines if two values are not the same. diff --git a/sdk/search/Azure.Search.Documents/src/Indexes/FieldBuilder.cs b/sdk/search/Azure.Search.Documents/src/Indexes/FieldBuilder.cs index dced1754d9e0d..fc175bd05357f 100644 --- a/sdk/search/Azure.Search.Documents/src/Indexes/FieldBuilder.cs +++ b/sdk/search/Azure.Search.Documents/src/Indexes/FieldBuilder.cs @@ -27,6 +27,8 @@ public class FieldBuilder new Dictionary() { [typeof(string)] = SearchFieldDataType.String, + [typeof(sbyte)] = SearchFieldDataType.SByte, + [typeof(short)] = SearchFieldDataType.Int16, [typeof(int)] = SearchFieldDataType.Int32, [typeof(long)] = SearchFieldDataType.Int64, [typeof(double)] = SearchFieldDataType.Double, diff --git a/sdk/search/Azure.Search.Documents/src/Indexes/Models/SearchFieldDataType.cs b/sdk/search/Azure.Search.Documents/src/Indexes/Models/SearchFieldDataType.cs index 8ff6e6de276d9..ad514147dd245 100644 --- a/sdk/search/Azure.Search.Documents/src/Indexes/Models/SearchFieldDataType.cs +++ b/sdk/search/Azure.Search.Documents/src/Indexes/Models/SearchFieldDataType.cs @@ -15,6 +15,14 @@ public readonly partial struct SearchFieldDataType [CodeGenMember("EdmString")] public static SearchFieldDataType String { get; } = new SearchFieldDataType(StringValue); + /// Indicates that a field contains a 8-bit signed integer. This is only valid when used with Collection(Edm.SByte). + [CodeGenMember("EdmSByte")] + public static SearchFieldDataType SByte { get; } = new SearchFieldDataType(SByteValue); + + /// Indicates that a field contains a 16-bit signed integer. This is only valid when used with Collection(Edm.Int16). + [CodeGenMember("EdmInt16")] + public static SearchFieldDataType Int16 { get; } = new SearchFieldDataType(Int16Value); + /// An type, or something that can convert to an . [CodeGenMember("EdmInt32")] public static SearchFieldDataType Int32 { get; } = new SearchFieldDataType(Int32Value); @@ -48,6 +56,10 @@ public readonly partial struct SearchFieldDataType [CodeGenMember("EdmSingle")] public static SearchFieldDataType Single { get; } = new SearchFieldDataType(SingleValue); + /// Indicates that a field contains a half-precision floating point number. This is only valid when used with Collection(Edm.Half). + [CodeGenMember("EdmHalf")] + public static SearchFieldDataType Half { get; } = new SearchFieldDataType(HalfValue); + /// /// Gets a representing a collection of . /// diff --git a/sdk/search/Azure.Search.Documents/tests/DocumentOperations/VectorSearchTests.cs b/sdk/search/Azure.Search.Documents/tests/DocumentOperations/VectorSearchTests.cs index c8b2649df2955..dd401371fc917 100644 --- a/sdk/search/Azure.Search.Documents/tests/DocumentOperations/VectorSearchTests.cs +++ b/sdk/search/Azure.Search.Documents/tests/DocumentOperations/VectorSearchTests.cs @@ -239,6 +239,7 @@ public async Task UpdateExistingIndexToAddVectorFields() } [Test] + [ServiceVersion(Min = SearchClientOptions.ServiceVersion.V2024_03_01_Preview)] public async Task UpdatingVectorProfileNameThrows() { await using SearchResources resources = SearchResources.CreateWithNoIndexes(this); @@ -519,6 +520,7 @@ public async Task CanUpdateIsHiddenAfterIndexCreation() } [Test] + [ServiceVersion(Min = SearchClientOptions.ServiceVersion.V2024_03_01_Preview)] public async Task CreateIndexUsingFieldBuilder() { await using SearchResources resources = SearchResources.CreateWithNoIndexes(this); diff --git a/sdk/search/Azure.Search.Documents/tests/FieldBuilderTests.cs b/sdk/search/Azure.Search.Documents/tests/FieldBuilderTests.cs index 65f11685945b1..dd1faf98b4aac 100644 --- a/sdk/search/Azure.Search.Documents/tests/FieldBuilderTests.cs +++ b/sdk/search/Azure.Search.Documents/tests/FieldBuilderTests.cs @@ -60,6 +60,8 @@ from typeAndField in primitiveSubFieldTestData (SearchFieldDataType, string)[] primitiveFieldTestData = new[] { (SearchFieldDataType.String, nameof(ReflectableModel.Text)), + (SearchFieldDataType.SByte, nameof(ReflectableModel.SByte)), + (SearchFieldDataType.Int16, nameof(ReflectableModel.Short)), (SearchFieldDataType.Int32, nameof(ReflectableModel.Id)), (SearchFieldDataType.Int64, nameof(ReflectableModel.BigNumber)), (SearchFieldDataType.Double, nameof(ReflectableModel.Double)), @@ -91,6 +93,16 @@ public static IEnumerable CollectionTypeTestData (SearchFieldDataType.String, nameof(ReflectableModel.StringIEnumerable)), (SearchFieldDataType.String, nameof(ReflectableModel.StringList)), (SearchFieldDataType.String, nameof(ReflectableModel.StringICollection)), + (SearchFieldDataType.SByte, nameof(ReflectableModel.SByteArray)), + (SearchFieldDataType.SByte, nameof(ReflectableModel.SByteIList)), + (SearchFieldDataType.SByte, nameof(ReflectableModel.SByteIEnumerable)), + (SearchFieldDataType.SByte, nameof(ReflectableModel.SByteList)), + (SearchFieldDataType.SByte, nameof(ReflectableModel.SByteICollection)), + (SearchFieldDataType.Int16, nameof(ReflectableModel.ShortArray)), + (SearchFieldDataType.Int16, nameof(ReflectableModel.ShortIList)), + (SearchFieldDataType.Int16, nameof(ReflectableModel.ShortIEnumerable)), + (SearchFieldDataType.Int16, nameof(ReflectableModel.ShortList)), + (SearchFieldDataType.Int16, nameof(ReflectableModel.ShortICollection)), (SearchFieldDataType.Int32, nameof(ReflectableModel.IntArray)), (SearchFieldDataType.Int32, nameof(ReflectableModel.IntIList)), (SearchFieldDataType.Int32, nameof(ReflectableModel.IntIEnumerable)), @@ -678,7 +690,7 @@ private class ModelWithVectorProperty [SimpleField(IsKey = true)] public string ID { get; set; } - [VectorSearchField(VectorSearchDimensions = 1536, VectorSearchProfileName = "test-config")] + [VectorSearchField(VectorSearchDimensions = 1536, VectorSearchProfileName = "test-config", IsStored = true)] public IReadOnlyList TitleVector { get; set; } } } diff --git a/sdk/search/Azure.Search.Documents/tests/Models/ReflectableModel.cs b/sdk/search/Azure.Search.Documents/tests/Models/ReflectableModel.cs index 083705169c6b7..a4c7b9c2e83f8 100644 --- a/sdk/search/Azure.Search.Documents/tests/Models/ReflectableModel.cs +++ b/sdk/search/Azure.Search.Documents/tests/Models/ReflectableModel.cs @@ -55,6 +55,10 @@ public class ReflectableModel public double Double { get; set; } + public sbyte SByte { get; set; } + + public short Short { get; set; } + public bool Flag { get; set; } public DateTimeOffset Time { get; set; } @@ -112,6 +116,26 @@ public class ReflectableModel public GeographyPoint GeographyPoint { get; set; } + public sbyte[] SByteArray { get; set; } + + public IList SByteIList { get; set; } + + public List SByteList { get; set; } + + public IEnumerable SByteIEnumerable { get; set; } + + public ICollection SByteICollection { get; set; } + + public short[] ShortArray { get; set; } + + public IList ShortIList { get; set; } + + public List ShortList { get; set; } + + public IEnumerable ShortIEnumerable { get; set; } + + public ICollection ShortICollection { get; set; } + public int[] IntArray { get; set; } public IList IntIList { get; set; } diff --git a/sdk/search/Azure.Search.Documents/tests/Models/ReflectableStructModel.cs b/sdk/search/Azure.Search.Documents/tests/Models/ReflectableStructModel.cs index 426ba2f07f18c..f78990895feaa 100644 --- a/sdk/search/Azure.Search.Documents/tests/Models/ReflectableStructModel.cs +++ b/sdk/search/Azure.Search.Documents/tests/Models/ReflectableStructModel.cs @@ -55,6 +55,10 @@ public struct ReflectableStructModel public double Double { get; set; } + public sbyte SByte { get; set; } + + public short Short { get; set; } + public bool Flag { get; set; } public DateTimeOffset Time { get; set; } @@ -109,6 +113,26 @@ public struct ReflectableStructModel public GeographyPoint GeographyPoint { get; set; } + public sbyte[] SByteArray { get; set; } + + public IList SByteIList { get; set; } + + public List SByteList { get; set; } + + public IEnumerable SByteIEnumerable { get; set; } + + public ICollection SByteICollection { get; set; } + + public short[] ShortArray { get; set; } + + public IList ShortIList { get; set; } + + public List ShortList { get; set; } + + public IEnumerable ShortIEnumerable { get; set; } + + public ICollection ShortICollection { get; set; } + public int[] IntArray { get; set; } public IList IntIList { get; set; } diff --git a/sdk/search/Azure.Search.Documents/tests/Samples/Sample07_VectorSearch_UsingFieldBuilder.cs b/sdk/search/Azure.Search.Documents/tests/Samples/Sample07_VectorSearch_UsingFieldBuilder.cs index 618a7c4fcbc7a..d24e2ecbec674 100644 --- a/sdk/search/Azure.Search.Documents/tests/Samples/Sample07_VectorSearch_UsingFieldBuilder.cs +++ b/sdk/search/Azure.Search.Documents/tests/Samples/Sample07_VectorSearch_UsingFieldBuilder.cs @@ -7,9 +7,11 @@ using Azure.Search.Documents.Indexes.Models; using Azure.Search.Documents.Indexes; using NUnit.Framework; +using Azure.Core.TestFramework; namespace Azure.Search.Documents.Tests.Samples.VectorSearch { + [ClientTestFixture(SearchClientOptions.ServiceVersion.V2024_03_01_Preview), ServiceVersion(Min = SearchClientOptions.ServiceVersion.V2024_03_01_Preview)] public partial class VectorSearchUsingFieldBuilder : SearchTestBase { public VectorSearchUsingFieldBuilder(bool async, SearchClientOptions.ServiceVersion serviceVersion) From 27a1dc8037c77fe428aad10a92292aa73ec4d9e9 Mon Sep 17 00:00:00 2001 From: ShivangiReja Date: Mon, 4 Mar 2024 12:55:43 -0800 Subject: [PATCH 2/3] Fix --- .../src/Generated/Models/SearchFieldDataType.cs | 2 ++ .../src/Indexes/Models/SearchFieldDataType.cs | 4 ---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchFieldDataType.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchFieldDataType.cs index 6f0cea7382fbe..273f89db0ff41 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchFieldDataType.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchFieldDataType.cs @@ -34,6 +34,8 @@ public SearchFieldDataType(string value) private const string HalfValue = "Edm.Half"; private const string Int16Value = "Edm.Int16"; private const string SByteValue = "Edm.SByte"; + /// Indicates that a field contains a half-precision floating point number. This is only valid when used with Collection(Edm.Half). + public static SearchFieldDataType Half { get; } = new SearchFieldDataType(HalfValue); /// Determines if two values are the same. public static bool operator ==(SearchFieldDataType left, SearchFieldDataType right) => left.Equals(right); /// Determines if two values are not the same. diff --git a/sdk/search/Azure.Search.Documents/src/Indexes/Models/SearchFieldDataType.cs b/sdk/search/Azure.Search.Documents/src/Indexes/Models/SearchFieldDataType.cs index ad514147dd245..2410c11fe7743 100644 --- a/sdk/search/Azure.Search.Documents/src/Indexes/Models/SearchFieldDataType.cs +++ b/sdk/search/Azure.Search.Documents/src/Indexes/Models/SearchFieldDataType.cs @@ -56,10 +56,6 @@ public readonly partial struct SearchFieldDataType [CodeGenMember("EdmSingle")] public static SearchFieldDataType Single { get; } = new SearchFieldDataType(SingleValue); - /// Indicates that a field contains a half-precision floating point number. This is only valid when used with Collection(Edm.Half). - [CodeGenMember("EdmHalf")] - public static SearchFieldDataType Half { get; } = new SearchFieldDataType(HalfValue); - /// /// Gets a representing a collection of . /// From 286c47a9d3f34574e4b8e55b0a3876ecf307f4b0 Mon Sep 17 00:00:00 2001 From: ShivangiReja Date: Mon, 4 Mar 2024 13:04:34 -0800 Subject: [PATCH 3/3] New recordings --- sdk/search/Azure.Search.Documents/assets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/search/Azure.Search.Documents/assets.json b/sdk/search/Azure.Search.Documents/assets.json index 5b3dd7aec3a62..af1896853b338 100644 --- a/sdk/search/Azure.Search.Documents/assets.json +++ b/sdk/search/Azure.Search.Documents/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "net/search/Azure.Search.Documents", - "Tag": "net/search/Azure.Search.Documents_53f1013bad" + "Tag": "net/search/Azure.Search.Documents_c617e35c0c" }