Skip to content
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

[Search] Add support for sbyte and int16 types to FieldBuilder #42378

Merged
merged 3 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sdk/search/Azure.Search.Documents/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion sdk/search/Azure.Search.Documents/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class FieldBuilder
new Dictionary<Type, SearchFieldDataType>()
{
[typeof(string)] = SearchFieldDataType.String,
[typeof(sbyte)] = SearchFieldDataType.SByte,
[typeof(short)] = SearchFieldDataType.Int16,
Comment on lines +30 to +31
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jairmyree FYI, we should do the same thing in Java for Int16, will need to look into if SByte can be supported

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Java has a concept of byte which is equivalent to SByte

[typeof(int)] = SearchFieldDataType.Int32,
[typeof(long)] = SearchFieldDataType.Int64,
[typeof(double)] = SearchFieldDataType.Double,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ public readonly partial struct SearchFieldDataType
[CodeGenMember("EdmString")]
public static SearchFieldDataType String { get; } = new SearchFieldDataType(StringValue);

/// <summary> Indicates that a field contains a 8-bit signed integer. This is only valid when used with Collection(Edm.SByte). </summary>
[CodeGenMember("EdmSByte")]
public static SearchFieldDataType SByte { get; } = new SearchFieldDataType(SByteValue);

/// <summary> Indicates that a field contains a 16-bit signed integer. This is only valid when used with Collection(Edm.Int16). </summary>
[CodeGenMember("EdmInt16")]
public static SearchFieldDataType Int16 { get; } = new SearchFieldDataType(Int16Value);

/// <summary>An <see cref="int"/> type, or something that can convert to an <see cref="int"/>.</summary>
[CodeGenMember("EdmInt32")]
public static SearchFieldDataType Int32 { get; } = new SearchFieldDataType(Int32Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
14 changes: 13 additions & 1 deletion sdk/search/Azure.Search.Documents/tests/FieldBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down Expand Up @@ -91,6 +93,16 @@ public static IEnumerable<TestCaseData> 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)),
Expand Down Expand Up @@ -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<float> TitleVector { get; set; }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -112,6 +116,26 @@ public class ReflectableModel

public GeographyPoint GeographyPoint { get; set; }

public sbyte[] SByteArray { get; set; }

public IList<sbyte> SByteIList { get; set; }

public List<sbyte> SByteList { get; set; }

public IEnumerable<sbyte> SByteIEnumerable { get; set; }

public ICollection<sbyte> SByteICollection { get; set; }

public short[] ShortArray { get; set; }

public IList<short> ShortIList { get; set; }

public List<short> ShortList { get; set; }

public IEnumerable<short> ShortIEnumerable { get; set; }

public ICollection<short> ShortICollection { get; set; }

public int[] IntArray { get; set; }

public IList<int> IntIList { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -109,6 +113,26 @@ public struct ReflectableStructModel

public GeographyPoint GeographyPoint { get; set; }

public sbyte[] SByteArray { get; set; }

public IList<sbyte> SByteIList { get; set; }

public List<sbyte> SByteList { get; set; }

public IEnumerable<sbyte> SByteIEnumerable { get; set; }

public ICollection<sbyte> SByteICollection { get; set; }

public short[] ShortArray { get; set; }

public IList<short> ShortIList { get; set; }

public List<short> ShortList { get; set; }

public IEnumerable<short> ShortIEnumerable { get; set; }

public ICollection<short> ShortICollection { get; set; }

public int[] IntArray { get; set; }

public IList<int> IntIList { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down