diff --git a/sdk/search/Azure.Search.Documents/api/Azure.Search.Documents.netstandard2.0.cs b/sdk/search/Azure.Search.Documents/api/Azure.Search.Documents.netstandard2.0.cs index d11b90fb6118..2202f325a6eb 100644 --- a/sdk/search/Azure.Search.Documents/api/Azure.Search.Documents.netstandard2.0.cs +++ b/sdk/search/Azure.Search.Documents/api/Azure.Search.Documents.netstandard2.0.cs @@ -339,13 +339,6 @@ public enum EdgeNGramTokenFilterSide Front = 0, Back = 1, } - public partial class EdgeNGramTokenFilterV2 : Azure.Search.Documents.Indexes.Models.TokenFilter - { - public EdgeNGramTokenFilterV2(string name) { } - public int? MaxGram { get { throw null; } set { } } - public int? MinGram { get { throw null; } set { } } - public Azure.Search.Documents.Indexes.Models.EdgeNGramTokenFilterSide? Side { get { throw null; } set { } } - } public partial class EdgeNGramTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer { public EdgeNGramTokenizer(string name) { } @@ -579,10 +572,6 @@ public partial class KeywordTokenizer : Azure.Search.Documents.Indexes.Models.Le { public KeywordTokenizer(string name) { } public int? BufferSize { get { throw null; } set { } } - } - public partial class KeywordTokenizerV2 : Azure.Search.Documents.Indexes.Models.LexicalTokenizer - { - public KeywordTokenizerV2(string name) { } public int? MaxTokenLength { get { throw null; } set { } } } public partial class LanguageDetectionSkill : Azure.Search.Documents.Indexes.Models.SearchIndexerSkill @@ -760,11 +749,6 @@ public partial class LuceneStandardTokenizer : Azure.Search.Documents.Indexes.Mo public LuceneStandardTokenizer(string name) { } public int? MaxTokenLength { get { throw null; } set { } } } - public partial class LuceneStandardTokenizerV2 : Azure.Search.Documents.Indexes.Models.LexicalTokenizer - { - public LuceneStandardTokenizerV2(string name) { } - public int? MaxTokenLength { get { throw null; } set { } } - } public partial class MagnitudeScoringFunction : Azure.Search.Documents.Indexes.Models.ScoringFunction { public MagnitudeScoringFunction(string fieldName, double boost, Azure.Search.Documents.Indexes.Models.MagnitudeScoringParameters parameters) { } @@ -901,12 +885,6 @@ public NGramTokenFilter(string name) { } public int? MaxGram { get { throw null; } set { } } public int? MinGram { get { throw null; } set { } } } - public partial class NGramTokenFilterV2 : Azure.Search.Documents.Indexes.Models.TokenFilter - { - public NGramTokenFilterV2(string name) { } - public int? MaxGram { get { throw null; } set { } } - public int? MinGram { get { throw null; } set { } } - } public partial class NGramTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer { public NGramTokenizer(string name) { } @@ -969,9 +947,9 @@ public OutputFieldMappingEntry(string name) { } public string Name { get { throw null; } set { } } public string TargetName { get { throw null; } set { } } } - public partial class PathHierarchyTokenizerV2 : Azure.Search.Documents.Indexes.Models.LexicalTokenizer + public partial class PathHierarchyTokenizer : Azure.Search.Documents.Indexes.Models.LexicalTokenizer { - public PathHierarchyTokenizerV2(string name) { } + public PathHierarchyTokenizer(string name) { } public char? Delimiter { get { throw null; } set { } } public int? MaxTokenLength { get { throw null; } set { } } public int? NumberOfTokensToSkip { get { throw null; } set { } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenFilter.Serialization.cs index aa46aa396b16..170f84a66c6e 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenFilter.Serialization.cs @@ -12,79 +12,5 @@ namespace Azure.Search.Documents.Indexes.Models { public partial class EdgeNGramTokenFilter : IUtf8JsonSerializable { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) - { - writer.WriteStartObject(); - if (MinGram != null) - { - writer.WritePropertyName("minGram"); - writer.WriteNumberValue(MinGram.Value); - } - if (MaxGram != null) - { - writer.WritePropertyName("maxGram"); - writer.WriteNumberValue(MaxGram.Value); - } - if (Side != null) - { - writer.WritePropertyName("side"); - writer.WriteStringValue(Side.Value.ToSerialString()); - } - writer.WritePropertyName("@odata.type"); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"); - writer.WriteStringValue(Name); - writer.WriteEndObject(); - } - - internal static EdgeNGramTokenFilter DeserializeEdgeNGramTokenFilter(JsonElement element) - { - int? minGram = default; - int? maxGram = default; - EdgeNGramTokenFilterSide? side = default; - string odataType = default; - string name = default; - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("minGram")) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - minGram = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("maxGram")) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - maxGram = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("side")) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - side = property.Value.GetString().ToEdgeNGramTokenFilterSide(); - continue; - } - if (property.NameEquals("@odata.type")) - { - odataType = property.Value.GetString(); - continue; - } - if (property.NameEquals("name")) - { - name = property.Value.GetString(); - continue; - } - } - return new EdgeNGramTokenFilter(odataType, name, minGram, maxGram, side); - } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenFilter.cs index 75a51eb90c1d..72465c201465 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenFilter.cs @@ -12,37 +12,5 @@ namespace Azure.Search.Documents.Indexes.Models /// Generates n-grams of the given size(s) starting from the front or the back of an input token. This token filter is implemented using Apache Lucene. public partial class EdgeNGramTokenFilter : TokenFilter { - /// Initializes a new instance of EdgeNGramTokenFilter. - /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. - public EdgeNGramTokenFilter(string name) : base(name) - { - if (name == null) - { - throw new ArgumentNullException(nameof(name)); - } - - ODataType = "#Microsoft.Azure.Search.EdgeNGramTokenFilter"; - } - - /// Initializes a new instance of EdgeNGramTokenFilter. - /// Identifies the concrete type of the token filter. - /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. - /// The minimum n-gram length. Default is 1. Must be less than the value of maxGram. - /// The maximum n-gram length. Default is 2. - /// Specifies which side of the input the n-gram should be generated from. Default is "front". - internal EdgeNGramTokenFilter(string oDataType, string name, int? minGram, int? maxGram, EdgeNGramTokenFilterSide? side) : base(oDataType, name) - { - MinGram = minGram; - MaxGram = maxGram; - Side = side; - ODataType = oDataType ?? "#Microsoft.Azure.Search.EdgeNGramTokenFilter"; - } - - /// The minimum n-gram length. Default is 1. Must be less than the value of maxGram. - public int? MinGram { get; set; } - /// The maximum n-gram length. Default is 2. - public int? MaxGram { get; set; } - /// Specifies which side of the input the n-gram should be generated from. Default is "front". - public EdgeNGramTokenFilterSide? Side { get; set; } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenFilterV2.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenFilterV2.cs deleted file mode 100644 index 13088483ccf8..000000000000 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenFilterV2.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; - -namespace Azure.Search.Documents.Indexes.Models -{ - /// Generates n-grams of the given size(s) starting from the front or the back of an input token. This token filter is implemented using Apache Lucene. - public partial class EdgeNGramTokenFilterV2 : TokenFilter - { - /// Initializes a new instance of EdgeNGramTokenFilterV2. - /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. - public EdgeNGramTokenFilterV2(string name) : base(name) - { - if (name == null) - { - throw new ArgumentNullException(nameof(name)); - } - - ODataType = "#Microsoft.Azure.Search.EdgeNGramTokenFilterV2"; - } - - /// Initializes a new instance of EdgeNGramTokenFilterV2. - /// Identifies the concrete type of the token filter. - /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. - /// The minimum n-gram length. Default is 1. Maximum is 300. Must be less than the value of maxGram. - /// The maximum n-gram length. Default is 2. Maximum is 300. - /// Specifies which side of the input the n-gram should be generated from. Default is "front". - internal EdgeNGramTokenFilterV2(string oDataType, string name, int? minGram, int? maxGram, EdgeNGramTokenFilterSide? side) : base(oDataType, name) - { - MinGram = minGram; - MaxGram = maxGram; - Side = side; - ODataType = oDataType ?? "#Microsoft.Azure.Search.EdgeNGramTokenFilterV2"; - } - - /// The minimum n-gram length. Default is 1. Maximum is 300. Must be less than the value of maxGram. - public int? MinGram { get; set; } - /// The maximum n-gram length. Default is 2. Maximum is 300. - public int? MaxGram { get; set; } - /// Specifies which side of the input the n-gram should be generated from. Default is "front". - public EdgeNGramTokenFilterSide? Side { get; set; } - } -} diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordTokenizer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordTokenizer.Serialization.cs index 83bb7c3aba4a..b92f36b248cd 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordTokenizer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordTokenizer.Serialization.cs @@ -12,49 +12,5 @@ namespace Azure.Search.Documents.Indexes.Models { public partial class KeywordTokenizer : IUtf8JsonSerializable { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) - { - writer.WriteStartObject(); - if (BufferSize != null) - { - writer.WritePropertyName("bufferSize"); - writer.WriteNumberValue(BufferSize.Value); - } - writer.WritePropertyName("@odata.type"); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"); - writer.WriteStringValue(Name); - writer.WriteEndObject(); - } - - internal static KeywordTokenizer DeserializeKeywordTokenizer(JsonElement element) - { - int? bufferSize = default; - string odataType = default; - string name = default; - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("bufferSize")) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - bufferSize = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("@odata.type")) - { - odataType = property.Value.GetString(); - continue; - } - if (property.NameEquals("name")) - { - name = property.Value.GetString(); - continue; - } - } - return new KeywordTokenizer(odataType, name, bufferSize); - } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordTokenizer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordTokenizer.cs index c40e52c674da..a7c9f087b376 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordTokenizer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordTokenizer.cs @@ -12,29 +12,5 @@ namespace Azure.Search.Documents.Indexes.Models /// Emits the entire input as a single token. This tokenizer is implemented using Apache Lucene. public partial class KeywordTokenizer : LexicalTokenizer { - /// Initializes a new instance of KeywordTokenizer. - /// The name of the tokenizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. - public KeywordTokenizer(string name) : base(name) - { - if (name == null) - { - throw new ArgumentNullException(nameof(name)); - } - - ODataType = "#Microsoft.Azure.Search.KeywordTokenizer"; - } - - /// Initializes a new instance of KeywordTokenizer. - /// Identifies the concrete type of the tokenizer. - /// The name of the tokenizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. - /// The read buffer size in bytes. Default is 256. - internal KeywordTokenizer(string oDataType, string name, int? bufferSize) : base(oDataType, name) - { - BufferSize = bufferSize; - ODataType = oDataType ?? "#Microsoft.Azure.Search.KeywordTokenizer"; - } - - /// The read buffer size in bytes. Default is 256. - public int? BufferSize { get; set; } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordTokenizerV2.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordTokenizerV2.Serialization.cs deleted file mode 100644 index cd18ed6b3022..000000000000 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordTokenizerV2.Serialization.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Text.Json; -using Azure.Core; - -namespace Azure.Search.Documents.Indexes.Models -{ - public partial class KeywordTokenizerV2 : IUtf8JsonSerializable - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) - { - writer.WriteStartObject(); - if (MaxTokenLength != null) - { - writer.WritePropertyName("maxTokenLength"); - writer.WriteNumberValue(MaxTokenLength.Value); - } - writer.WritePropertyName("@odata.type"); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"); - writer.WriteStringValue(Name); - writer.WriteEndObject(); - } - - internal static KeywordTokenizerV2 DeserializeKeywordTokenizerV2(JsonElement element) - { - int? maxTokenLength = default; - string odataType = default; - string name = default; - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("maxTokenLength")) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - maxTokenLength = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("@odata.type")) - { - odataType = property.Value.GetString(); - continue; - } - if (property.NameEquals("name")) - { - name = property.Value.GetString(); - continue; - } - } - return new KeywordTokenizerV2(odataType, name, maxTokenLength); - } - } -} diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordTokenizerV2.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordTokenizerV2.cs deleted file mode 100644 index ae37d1135765..000000000000 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/KeywordTokenizerV2.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; - -namespace Azure.Search.Documents.Indexes.Models -{ - /// Emits the entire input as a single token. This tokenizer is implemented using Apache Lucene. - public partial class KeywordTokenizerV2 : LexicalTokenizer - { - /// Initializes a new instance of KeywordTokenizerV2. - /// The name of the tokenizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. - public KeywordTokenizerV2(string name) : base(name) - { - if (name == null) - { - throw new ArgumentNullException(nameof(name)); - } - - ODataType = "#Microsoft.Azure.Search.KeywordTokenizerV2"; - } - - /// Initializes a new instance of KeywordTokenizerV2. - /// Identifies the concrete type of the tokenizer. - /// The name of the tokenizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. - /// The maximum token length. Default is 256. Tokens longer than the maximum length are split. The maximum token length that can be used is 300 characters. - internal KeywordTokenizerV2(string oDataType, string name, int? maxTokenLength) : base(oDataType, name) - { - MaxTokenLength = maxTokenLength; - ODataType = oDataType ?? "#Microsoft.Azure.Search.KeywordTokenizerV2"; - } - - /// The maximum token length. Default is 256. Tokens longer than the maximum length are split. The maximum token length that can be used is 300 characters. - public int? MaxTokenLength { get; set; } - } -} diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalTokenizer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalTokenizer.Serialization.cs index bc743b149668..ccb622de959a 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalTokenizer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/LexicalTokenizer.Serialization.cs @@ -31,14 +31,14 @@ internal static LexicalTokenizer DeserializeLexicalTokenizer(JsonElement element case "#Microsoft.Azure.Search.ClassicTokenizer": return ClassicTokenizer.DeserializeClassicTokenizer(element); case "#Microsoft.Azure.Search.EdgeNGramTokenizer": return EdgeNGramTokenizer.DeserializeEdgeNGramTokenizer(element); case "#Microsoft.Azure.Search.KeywordTokenizer": return KeywordTokenizer.DeserializeKeywordTokenizer(element); - case "#Microsoft.Azure.Search.KeywordTokenizerV2": return KeywordTokenizerV2.DeserializeKeywordTokenizerV2(element); + case "#Microsoft.Azure.Search.KeywordTokenizerV2": return KeywordTokenizer.DeserializeKeywordTokenizer(element); case "#Microsoft.Azure.Search.MicrosoftLanguageStemmingTokenizer": return MicrosoftLanguageStemmingTokenizer.DeserializeMicrosoftLanguageStemmingTokenizer(element); case "#Microsoft.Azure.Search.MicrosoftLanguageTokenizer": return MicrosoftLanguageTokenizer.DeserializeMicrosoftLanguageTokenizer(element); case "#Microsoft.Azure.Search.NGramTokenizer": return NGramTokenizer.DeserializeNGramTokenizer(element); - case "#Microsoft.Azure.Search.PathHierarchyTokenizerV2": return PathHierarchyTokenizerV2.DeserializePathHierarchyTokenizerV2(element); + case "#Microsoft.Azure.Search.PathHierarchyTokenizerV2": return PathHierarchyTokenizer.DeserializePathHierarchyTokenizer(element); case "#Microsoft.Azure.Search.PatternTokenizer": return PatternTokenizer.DeserializePatternTokenizer(element); case "#Microsoft.Azure.Search.StandardTokenizer": return LuceneStandardTokenizer.DeserializeLuceneStandardTokenizer(element); - case "#Microsoft.Azure.Search.StandardTokenizerV2": return LuceneStandardTokenizerV2.DeserializeLuceneStandardTokenizerV2(element); + case "#Microsoft.Azure.Search.StandardTokenizerV2": return LuceneStandardTokenizer.DeserializeLuceneStandardTokenizer(element); case "#Microsoft.Azure.Search.UaxUrlEmailTokenizer": return UaxUrlEmailTokenizer.DeserializeUaxUrlEmailTokenizer(element); } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardTokenizer.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardTokenizer.Serialization.cs index d423a0393315..b1a921b0893a 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardTokenizer.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardTokenizer.Serialization.cs @@ -12,49 +12,5 @@ namespace Azure.Search.Documents.Indexes.Models { public partial class LuceneStandardTokenizer : IUtf8JsonSerializable { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) - { - writer.WriteStartObject(); - if (MaxTokenLength != null) - { - writer.WritePropertyName("maxTokenLength"); - writer.WriteNumberValue(MaxTokenLength.Value); - } - writer.WritePropertyName("@odata.type"); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"); - writer.WriteStringValue(Name); - writer.WriteEndObject(); - } - - internal static LuceneStandardTokenizer DeserializeLuceneStandardTokenizer(JsonElement element) - { - int? maxTokenLength = default; - string odataType = default; - string name = default; - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("maxTokenLength")) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - maxTokenLength = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("@odata.type")) - { - odataType = property.Value.GetString(); - continue; - } - if (property.NameEquals("name")) - { - name = property.Value.GetString(); - continue; - } - } - return new LuceneStandardTokenizer(odataType, name, maxTokenLength); - } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardTokenizer.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardTokenizer.cs index 22c3eacfa8b1..823541f9e403 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardTokenizer.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardTokenizer.cs @@ -12,29 +12,5 @@ namespace Azure.Search.Documents.Indexes.Models /// Breaks text following the Unicode Text Segmentation rules. This tokenizer is implemented using Apache Lucene. public partial class LuceneStandardTokenizer : LexicalTokenizer { - /// Initializes a new instance of LuceneStandardTokenizer. - /// The name of the tokenizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. - public LuceneStandardTokenizer(string name) : base(name) - { - if (name == null) - { - throw new ArgumentNullException(nameof(name)); - } - - ODataType = "#Microsoft.Azure.Search.StandardTokenizer"; - } - - /// Initializes a new instance of LuceneStandardTokenizer. - /// Identifies the concrete type of the tokenizer. - /// The name of the tokenizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. - /// The maximum token length. Default is 255. Tokens longer than the maximum length are split. - internal LuceneStandardTokenizer(string oDataType, string name, int? maxTokenLength) : base(oDataType, name) - { - MaxTokenLength = maxTokenLength; - ODataType = oDataType ?? "#Microsoft.Azure.Search.StandardTokenizer"; - } - - /// The maximum token length. Default is 255. Tokens longer than the maximum length are split. - public int? MaxTokenLength { get; set; } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardTokenizerV2.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardTokenizerV2.cs deleted file mode 100644 index cc9ddefc5bc1..000000000000 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardTokenizerV2.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; - -namespace Azure.Search.Documents.Indexes.Models -{ - /// Breaks text following the Unicode Text Segmentation rules. This tokenizer is implemented using Apache Lucene. - public partial class LuceneStandardTokenizerV2 : LexicalTokenizer - { - /// Initializes a new instance of LuceneStandardTokenizerV2. - /// The name of the tokenizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. - public LuceneStandardTokenizerV2(string name) : base(name) - { - if (name == null) - { - throw new ArgumentNullException(nameof(name)); - } - - ODataType = "#Microsoft.Azure.Search.StandardTokenizerV2"; - } - - /// Initializes a new instance of LuceneStandardTokenizerV2. - /// Identifies the concrete type of the tokenizer. - /// The name of the tokenizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. - /// The maximum token length. Default is 255. Tokens longer than the maximum length are split. The maximum token length that can be used is 300 characters. - internal LuceneStandardTokenizerV2(string oDataType, string name, int? maxTokenLength) : base(oDataType, name) - { - MaxTokenLength = maxTokenLength; - ODataType = oDataType ?? "#Microsoft.Azure.Search.StandardTokenizerV2"; - } - - /// The maximum token length. Default is 255. Tokens longer than the maximum length are split. The maximum token length that can be used is 300 characters. - public int? MaxTokenLength { get; set; } - } -} diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenFilter.Serialization.cs index 27bf63deb16e..8d8e417a2135 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenFilter.Serialization.cs @@ -12,64 +12,5 @@ namespace Azure.Search.Documents.Indexes.Models { public partial class NGramTokenFilter : IUtf8JsonSerializable { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) - { - writer.WriteStartObject(); - if (MinGram != null) - { - writer.WritePropertyName("minGram"); - writer.WriteNumberValue(MinGram.Value); - } - if (MaxGram != null) - { - writer.WritePropertyName("maxGram"); - writer.WriteNumberValue(MaxGram.Value); - } - writer.WritePropertyName("@odata.type"); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"); - writer.WriteStringValue(Name); - writer.WriteEndObject(); - } - - internal static NGramTokenFilter DeserializeNGramTokenFilter(JsonElement element) - { - int? minGram = default; - int? maxGram = default; - string odataType = default; - string name = default; - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("minGram")) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - minGram = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("maxGram")) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - maxGram = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("@odata.type")) - { - odataType = property.Value.GetString(); - continue; - } - if (property.NameEquals("name")) - { - name = property.Value.GetString(); - continue; - } - } - return new NGramTokenFilter(odataType, name, minGram, maxGram); - } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenFilter.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenFilter.cs index f4ee851676a8..423858fa3c89 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenFilter.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenFilter.cs @@ -12,33 +12,5 @@ namespace Azure.Search.Documents.Indexes.Models /// Generates n-grams of the given size(s). This token filter is implemented using Apache Lucene. public partial class NGramTokenFilter : TokenFilter { - /// Initializes a new instance of NGramTokenFilter. - /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. - public NGramTokenFilter(string name) : base(name) - { - if (name == null) - { - throw new ArgumentNullException(nameof(name)); - } - - ODataType = "#Microsoft.Azure.Search.NGramTokenFilter"; - } - - /// Initializes a new instance of NGramTokenFilter. - /// Identifies the concrete type of the token filter. - /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. - /// The minimum n-gram length. Default is 1. Must be less than the value of maxGram. - /// The maximum n-gram length. Default is 2. - internal NGramTokenFilter(string oDataType, string name, int? minGram, int? maxGram) : base(oDataType, name) - { - MinGram = minGram; - MaxGram = maxGram; - ODataType = oDataType ?? "#Microsoft.Azure.Search.NGramTokenFilter"; - } - - /// The minimum n-gram length. Default is 1. Must be less than the value of maxGram. - public int? MinGram { get; set; } - /// The maximum n-gram length. Default is 2. - public int? MaxGram { get; set; } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenFilterV2.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenFilterV2.cs deleted file mode 100644 index 3d5f36c72e4d..000000000000 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenFilterV2.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; - -namespace Azure.Search.Documents.Indexes.Models -{ - /// Generates n-grams of the given size(s). This token filter is implemented using Apache Lucene. - public partial class NGramTokenFilterV2 : TokenFilter - { - /// Initializes a new instance of NGramTokenFilterV2. - /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. - public NGramTokenFilterV2(string name) : base(name) - { - if (name == null) - { - throw new ArgumentNullException(nameof(name)); - } - - ODataType = "#Microsoft.Azure.Search.NGramTokenFilterV2"; - } - - /// Initializes a new instance of NGramTokenFilterV2. - /// Identifies the concrete type of the token filter. - /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. - /// The minimum n-gram length. Default is 1. Maximum is 300. Must be less than the value of maxGram. - /// The maximum n-gram length. Default is 2. Maximum is 300. - internal NGramTokenFilterV2(string oDataType, string name, int? minGram, int? maxGram) : base(oDataType, name) - { - MinGram = minGram; - MaxGram = maxGram; - ODataType = oDataType ?? "#Microsoft.Azure.Search.NGramTokenFilterV2"; - } - - /// The minimum n-gram length. Default is 1. Maximum is 300. Must be less than the value of maxGram. - public int? MinGram { get; set; } - /// The maximum n-gram length. Default is 2. Maximum is 300. - public int? MaxGram { get; set; } - } -} diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/PathHierarchyTokenizerV2.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/PathHierarchyTokenizer.Serialization.cs similarity index 92% rename from sdk/search/Azure.Search.Documents/src/Generated/Models/PathHierarchyTokenizerV2.Serialization.cs rename to sdk/search/Azure.Search.Documents/src/Generated/Models/PathHierarchyTokenizer.Serialization.cs index fb661f8e0983..d3c962c0fc1b 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/PathHierarchyTokenizerV2.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/PathHierarchyTokenizer.Serialization.cs @@ -10,7 +10,7 @@ namespace Azure.Search.Documents.Indexes.Models { - public partial class PathHierarchyTokenizerV2 : IUtf8JsonSerializable + public partial class PathHierarchyTokenizer : IUtf8JsonSerializable { void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { @@ -47,7 +47,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteEndObject(); } - internal static PathHierarchyTokenizerV2 DeserializePathHierarchyTokenizerV2(JsonElement element) + internal static PathHierarchyTokenizer DeserializePathHierarchyTokenizer(JsonElement element) { char? delimiter = default; char? replacement = default; @@ -114,7 +114,7 @@ internal static PathHierarchyTokenizerV2 DeserializePathHierarchyTokenizerV2(Jso continue; } } - return new PathHierarchyTokenizerV2(odataType, name, delimiter, replacement, maxTokenLength, reverse, skip); + return new PathHierarchyTokenizer(odataType, name, delimiter, replacement, maxTokenLength, reverse, skip); } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/PathHierarchyTokenizerV2.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/PathHierarchyTokenizer.cs similarity index 88% rename from sdk/search/Azure.Search.Documents/src/Generated/Models/PathHierarchyTokenizerV2.cs rename to sdk/search/Azure.Search.Documents/src/Generated/Models/PathHierarchyTokenizer.cs index f2ac1ed54eb7..249e2ed6f01c 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/PathHierarchyTokenizerV2.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/PathHierarchyTokenizer.cs @@ -10,11 +10,11 @@ namespace Azure.Search.Documents.Indexes.Models { /// Tokenizer for path-like hierarchies. This tokenizer is implemented using Apache Lucene. - public partial class PathHierarchyTokenizerV2 : LexicalTokenizer + public partial class PathHierarchyTokenizer : LexicalTokenizer { - /// Initializes a new instance of PathHierarchyTokenizerV2. + /// Initializes a new instance of PathHierarchyTokenizer. /// The name of the tokenizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. - public PathHierarchyTokenizerV2(string name) : base(name) + public PathHierarchyTokenizer(string name) : base(name) { if (name == null) { @@ -24,7 +24,7 @@ public PathHierarchyTokenizerV2(string name) : base(name) ODataType = "#Microsoft.Azure.Search.PathHierarchyTokenizerV2"; } - /// Initializes a new instance of PathHierarchyTokenizerV2. + /// Initializes a new instance of PathHierarchyTokenizer. /// Identifies the concrete type of the tokenizer. /// The name of the tokenizer. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. /// The delimiter character to use. Default is "/". @@ -32,7 +32,7 @@ public PathHierarchyTokenizerV2(string name) : base(name) /// The maximum token length. Default and maximum is 300. /// A value indicating whether to generate tokens in reverse order. Default is false. /// The number of initial tokens to skip. Default is 0. - internal PathHierarchyTokenizerV2(string oDataType, string name, char? delimiter, char? replacement, int? maxTokenLength, bool? reverseTokenOrder, int? numberOfTokensToSkip) : base(oDataType, name) + internal PathHierarchyTokenizer(string oDataType, string name, char? delimiter, char? replacement, int? maxTokenLength, bool? reverseTokenOrder, int? numberOfTokensToSkip) : base(oDataType, name) { Delimiter = delimiter; Replacement = replacement; diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/TokenFilter.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/TokenFilter.Serialization.cs index b2c8a0d36fd8..00bd316488f0 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/TokenFilter.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/TokenFilter.Serialization.cs @@ -33,14 +33,14 @@ internal static TokenFilter DeserializeTokenFilter(JsonElement element) case "#Microsoft.Azure.Search.CommonGramTokenFilter": return CommonGramTokenFilter.DeserializeCommonGramTokenFilter(element); case "#Microsoft.Azure.Search.DictionaryDecompounderTokenFilter": return DictionaryDecompounderTokenFilter.DeserializeDictionaryDecompounderTokenFilter(element); case "#Microsoft.Azure.Search.EdgeNGramTokenFilter": return EdgeNGramTokenFilter.DeserializeEdgeNGramTokenFilter(element); - case "#Microsoft.Azure.Search.EdgeNGramTokenFilterV2": return EdgeNGramTokenFilterV2.DeserializeEdgeNGramTokenFilterV2(element); + case "#Microsoft.Azure.Search.EdgeNGramTokenFilterV2": return EdgeNGramTokenFilter.DeserializeEdgeNGramTokenFilter(element); case "#Microsoft.Azure.Search.ElisionTokenFilter": return ElisionTokenFilter.DeserializeElisionTokenFilter(element); case "#Microsoft.Azure.Search.KeepTokenFilter": return KeepTokenFilter.DeserializeKeepTokenFilter(element); case "#Microsoft.Azure.Search.KeywordMarkerTokenFilter": return KeywordMarkerTokenFilter.DeserializeKeywordMarkerTokenFilter(element); case "#Microsoft.Azure.Search.LengthTokenFilter": return LengthTokenFilter.DeserializeLengthTokenFilter(element); case "#Microsoft.Azure.Search.LimitTokenFilter": return LimitTokenFilter.DeserializeLimitTokenFilter(element); case "#Microsoft.Azure.Search.NGramTokenFilter": return NGramTokenFilter.DeserializeNGramTokenFilter(element); - case "#Microsoft.Azure.Search.NGramTokenFilterV2": return NGramTokenFilterV2.DeserializeNGramTokenFilterV2(element); + case "#Microsoft.Azure.Search.NGramTokenFilterV2": return NGramTokenFilter.DeserializeNGramTokenFilter(element); case "#Microsoft.Azure.Search.PatternCaptureTokenFilter": return PatternCaptureTokenFilter.DeserializePatternCaptureTokenFilter(element); case "#Microsoft.Azure.Search.PatternReplaceTokenFilter": return PatternReplaceTokenFilter.DeserializePatternReplaceTokenFilter(element); case "#Microsoft.Azure.Search.PhoneticTokenFilter": return PhoneticTokenFilter.DeserializePhoneticTokenFilter(element); diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenFilterV2.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Indexes/Models/EdgeNGramTokenFilter.cs similarity index 58% rename from sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenFilterV2.Serialization.cs rename to sdk/search/Azure.Search.Documents/src/Indexes/Models/EdgeNGramTokenFilter.cs index da024388a9ad..4c3a248a2b39 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/EdgeNGramTokenFilterV2.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Indexes/Models/EdgeNGramTokenFilter.cs @@ -1,51 +1,92 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// - -#nullable disable - using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class EdgeNGramTokenFilterV2 : IUtf8JsonSerializable + [CodeGenModel("EdgeNGramTokenFilterV2")] + [CodeGenSuppress(nameof(EdgeNGramTokenFilter), typeof(string), typeof(string), typeof(int?), typeof(int?), typeof(EdgeNGramTokenFilterSide?))] + public partial class EdgeNGramTokenFilter : IUtf8JsonSerializable { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + /// Initializes a new instance of EdgeNGramTokenFilter. + /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, can only start and end with alphanumeric characters, and is limited to 128 characters. + public EdgeNGramTokenFilter(string name) : base(name) + { + Argument.AssertNotNull(name, nameof(name)); + + ODataType = "#Microsoft.Azure.Search.EdgeNGramTokenFilterV2"; + } + + /// + /// The minimum n-gram length. Default is 1. Must be less than the value of maxGram. + /// + public int? MinGram { get; set; } + + /// + /// The maximum n-gram length. Default is 2. + /// + public int? MaxGram { get; set; } + + /// + /// Specifies which side of the input the n-gram should be generated from. Default is . + /// + public EdgeNGramTokenFilterSide? Side { get; set; } + + void global::Azure.Core.IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); + + writer.WritePropertyName("@odata.type"); + writer.WriteStringValue(ODataType); + + writer.WritePropertyName("name"); + writer.WriteStringValue(Name); + if (MinGram != null) { writer.WritePropertyName("minGram"); writer.WriteNumberValue(MinGram.Value); } + if (MaxGram != null) { writer.WritePropertyName("maxGram"); writer.WriteNumberValue(MaxGram.Value); } + if (Side != null) { writer.WritePropertyName("side"); writer.WriteStringValue(Side.Value.ToSerialString()); } - writer.WritePropertyName("@odata.type"); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"); - writer.WriteStringValue(Name); + writer.WriteEndObject(); } - internal static EdgeNGramTokenFilterV2 DeserializeEdgeNGramTokenFilterV2(JsonElement element) + internal static EdgeNGramTokenFilter DeserializeEdgeNGramTokenFilter(JsonElement element) { int? minGram = default; int? maxGram = default; EdgeNGramTokenFilterSide? side = default; string odataType = default; string name = default; + foreach (var property in element.EnumerateObject()) { + if (property.NameEquals("@odata.type")) + { + odataType = property.Value.GetString(); + continue; + } + + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("minGram")) { if (property.Value.ValueKind == JsonValueKind.Null) @@ -55,6 +96,7 @@ internal static EdgeNGramTokenFilterV2 DeserializeEdgeNGramTokenFilterV2(JsonEle minGram = property.Value.GetInt32(); continue; } + if (property.NameEquals("maxGram")) { if (property.Value.ValueKind == JsonValueKind.Null) @@ -64,6 +106,7 @@ internal static EdgeNGramTokenFilterV2 DeserializeEdgeNGramTokenFilterV2(JsonEle maxGram = property.Value.GetInt32(); continue; } + if (property.NameEquals("side")) { if (property.Value.ValueKind == JsonValueKind.Null) @@ -73,18 +116,15 @@ internal static EdgeNGramTokenFilterV2 DeserializeEdgeNGramTokenFilterV2(JsonEle side = property.Value.GetString().ToEdgeNGramTokenFilterSide(); continue; } - if (property.NameEquals("@odata.type")) - { - odataType = property.Value.GetString(); - continue; - } - if (property.NameEquals("name")) - { - name = property.Value.GetString(); - continue; - } } - return new EdgeNGramTokenFilterV2(odataType, name, minGram, maxGram, side); + + return new EdgeNGramTokenFilter(name) + { + ODataType = odataType, + MinGram = minGram, + MaxGram = maxGram, + Side = side, + }; } } } diff --git a/sdk/search/Azure.Search.Documents/src/Indexes/Models/KeywordTokenizer.cs b/sdk/search/Azure.Search.Documents/src/Indexes/Models/KeywordTokenizer.cs new file mode 100644 index 000000000000..306c825a2782 --- /dev/null +++ b/sdk/search/Azure.Search.Documents/src/Indexes/Models/KeywordTokenizer.cs @@ -0,0 +1,118 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Text.Json; +using Azure.Core; + +namespace Azure.Search.Documents.Indexes.Models +{ + [CodeGenModel("KeywordTokenizerV2")] + [CodeGenSuppress(nameof(KeywordTokenizer), typeof(string), typeof(string), typeof(int?))] + public partial class KeywordTokenizer : IUtf8JsonSerializable + { + /// + /// Initializes a new instance of KeywordTokenizer. + /// + /// + /// The name of the tokenizer. It must only contain letters, digits, spaces, + /// dashes or underscores, can only start and end with alphanumeric characters, + /// and is limited to 128 characters. + /// + public KeywordTokenizer(string name) : base(name) + { + Argument.AssertNotNull(name, nameof(name)); + + ODataType = "#Microsoft.Azure.Search.KeywordTokenizerV2"; + } + + /// + /// The read buffer size in bytes. Default is 256. + /// Setting this property on new instances of may result in an error + /// when sending new requests to the Azure Cognitive Search service. + /// + public int? BufferSize { get; set; } + + /// + /// The maximum token length. Default is 256. + /// Tokens longer than the maximum length are split. + /// The maximum token length that can be used is 300 characters. + /// + public int? MaxTokenLength { get; set; } + + // Use global scope to fully qualify name to work around bug in generator currently. + void global::Azure.Core.IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + + writer.WritePropertyName("@odata.type"); + writer.WriteStringValue(ODataType); + + writer.WritePropertyName("name"); + writer.WriteStringValue(Name); + + if (BufferSize != null) + { + writer.WritePropertyName("bufferSize"); + writer.WriteNumberValue(BufferSize.Value); + } + + if (MaxTokenLength != null) + { + writer.WritePropertyName("maxTokenLength"); + writer.WriteNumberValue(MaxTokenLength.Value); + } + + writer.WriteEndObject(); + } + + internal static KeywordTokenizer DeserializeKeywordTokenizer(JsonElement element) + { + int? bufferSize = default; + int? maxTokenLength = default; + string odataType = default; + string name = default; + + foreach (JsonProperty property in element.EnumerateObject()) + { + if (property.NameEquals("@odata.type")) + { + odataType = property.Value.GetString(); + continue; + } + + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + + if (property.NameEquals("bufferSize")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + bufferSize = property.Value.GetInt32(); + continue; + } + + if (property.NameEquals("maxTokenLength")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxTokenLength = property.Value.GetInt32(); + continue; + } + } + + return new KeywordTokenizer(name) + { + ODataType = odataType, + BufferSize = bufferSize, + MaxTokenLength = maxTokenLength, + }; + } + } +} diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardTokenizerV2.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Indexes/Models/LuceneStandardTokenizer.cs similarity index 50% rename from sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardTokenizerV2.Serialization.cs rename to sdk/search/Azure.Search.Documents/src/Indexes/Models/LuceneStandardTokenizer.cs index b270d23082cd..fd24d1668ccc 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/LuceneStandardTokenizerV2.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Indexes/Models/LuceneStandardTokenizer.cs @@ -1,18 +1,37 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// - -#nullable disable - using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class LuceneStandardTokenizerV2 : IUtf8JsonSerializable + [CodeGenModel("LuceneStandardTokenizerV2")] + [CodeGenSuppress(nameof(LuceneStandardTokenizer), typeof(string), typeof(string), typeof(int?))] + public partial class LuceneStandardTokenizer : IUtf8JsonSerializable { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + /// + /// Initializes a new instance of LuceneStandardTokenizer. + /// + /// + /// The name of the tokenizer. It must only contain letters, digits, spaces, dashes or underscores, + /// can only start and end with alphanumeric characters, and is limited to 128 characters. + /// + public LuceneStandardTokenizer(string name) : base(name) + { + Argument.AssertNotNull(name, nameof(name)); + + ODataType = "#Microsoft.Azure.Search.StandardTokenizerV2"; + } + + /// + /// The maximum token length. Default is 255. + /// Tokens longer than the maximum length are split. + /// The maximum token length that can be used is 300 characters. + /// + public int? MaxTokenLength { get; set; } + + void global::Azure.Core.IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); if (MaxTokenLength != null) @@ -27,34 +46,42 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteEndObject(); } - internal static LuceneStandardTokenizerV2 DeserializeLuceneStandardTokenizerV2(JsonElement element) + internal static LuceneStandardTokenizer DeserializeLuceneStandardTokenizer(JsonElement element) { int? maxTokenLength = default; string odataType = default; string name = default; + foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("maxTokenLength")) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - maxTokenLength = property.Value.GetInt32(); - continue; - } if (property.NameEquals("@odata.type")) { odataType = property.Value.GetString(); continue; } + if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } + + if (property.NameEquals("maxTokenLength")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxTokenLength = property.Value.GetInt32(); + continue; + } } - return new LuceneStandardTokenizerV2(odataType, name, maxTokenLength); + + return new LuceneStandardTokenizer(name) + { + ODataType = odataType, + MaxTokenLength = maxTokenLength, + }; } } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenFilterV2.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Indexes/Models/NGramTokenFilter.cs similarity index 55% rename from sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenFilterV2.Serialization.cs rename to sdk/search/Azure.Search.Documents/src/Indexes/Models/NGramTokenFilter.cs index 33d9545232dd..1c6bfd7675de 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/NGramTokenFilterV2.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Indexes/Models/NGramTokenFilter.cs @@ -1,38 +1,68 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// - -#nullable disable - using System.Text.Json; using Azure.Core; namespace Azure.Search.Documents.Indexes.Models { - public partial class NGramTokenFilterV2 : IUtf8JsonSerializable + [CodeGenModel("NGramTokenFilterV2")] + [CodeGenSuppress(nameof(NGramTokenFilter), typeof(string), typeof(string), typeof(int?), typeof(int?))] + public partial class NGramTokenFilter : IUtf8JsonSerializable { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + /// + /// Initializes a new instance of NGramTokenFilter. + /// + /// + /// The name of the token filter. It must only contain letters, digits, spaces, dashes or underscores, + /// can only start and end with alphanumeric characters, and is limited to 128 characters. + /// + public NGramTokenFilter(string name) : base(name) + { + Argument.AssertNotNull(name, nameof(name)); + + ODataType = "#Microsoft.Azure.Search.NGramTokenFilterV2"; + } + + /// + /// The minimum n-gram length. Default is 1. + /// Maximum is 300. + /// Must be less than the value of maxGram. + /// + public int? MinGram { get; set; } + + /// + /// The maximum n-gram length. Default is 2. + /// Maximum is 300. + /// + public int? MaxGram { get; set; } + + void global::Azure.Core.IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); + + writer.WritePropertyName("@odata.type"); + writer.WriteStringValue(ODataType); + + writer.WritePropertyName("name"); + writer.WriteStringValue(Name); + if (MinGram != null) { writer.WritePropertyName("minGram"); writer.WriteNumberValue(MinGram.Value); } + if (MaxGram != null) { writer.WritePropertyName("maxGram"); writer.WriteNumberValue(MaxGram.Value); } - writer.WritePropertyName("@odata.type"); - writer.WriteStringValue(ODataType); - writer.WritePropertyName("name"); - writer.WriteStringValue(Name); + writer.WriteEndObject(); } - internal static NGramTokenFilterV2 DeserializeNGramTokenFilterV2(JsonElement element) + internal static NGramTokenFilter DeserializeNGramTokenFilter(JsonElement element) { int? minGram = default; int? maxGram = default; @@ -40,6 +70,18 @@ internal static NGramTokenFilterV2 DeserializeNGramTokenFilterV2(JsonElement ele string name = default; foreach (var property in element.EnumerateObject()) { + if (property.NameEquals("@odata.type")) + { + odataType = property.Value.GetString(); + continue; + } + + if (property.NameEquals("name")) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("minGram")) { if (property.Value.ValueKind == JsonValueKind.Null) @@ -49,6 +91,7 @@ internal static NGramTokenFilterV2 DeserializeNGramTokenFilterV2(JsonElement ele minGram = property.Value.GetInt32(); continue; } + if (property.NameEquals("maxGram")) { if (property.Value.ValueKind == JsonValueKind.Null) @@ -58,18 +101,14 @@ internal static NGramTokenFilterV2 DeserializeNGramTokenFilterV2(JsonElement ele maxGram = property.Value.GetInt32(); continue; } - if (property.NameEquals("@odata.type")) - { - odataType = property.Value.GetString(); - continue; - } - if (property.NameEquals("name")) - { - name = property.Value.GetString(); - continue; - } } - return new NGramTokenFilterV2(odataType, name, minGram, maxGram); + + return new NGramTokenFilter(name) + { + ODataType = odataType, + MinGram = minGram, + MaxGram = maxGram, + }; } } } diff --git a/sdk/search/Azure.Search.Documents/src/Indexes/Models/PathHierarchyTokenizer.cs b/sdk/search/Azure.Search.Documents/src/Indexes/Models/PathHierarchyTokenizer.cs new file mode 100644 index 000000000000..a3af3371b2fa --- /dev/null +++ b/sdk/search/Azure.Search.Documents/src/Indexes/Models/PathHierarchyTokenizer.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.Search.Documents.Indexes.Models +{ + [CodeGenModel("PathHierarchyTokenizerV2")] + public partial class PathHierarchyTokenizer + { + } +} diff --git a/sdk/search/Azure.Search.Documents/tests/Models/EdgeNGramTokenFilterTests.cs b/sdk/search/Azure.Search.Documents/tests/Models/EdgeNGramTokenFilterTests.cs new file mode 100644 index 000000000000..48dda08cd592 --- /dev/null +++ b/sdk/search/Azure.Search.Documents/tests/Models/EdgeNGramTokenFilterTests.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.IO; +using System.Text.Json; +using Azure.Core; +using Azure.Search.Documents.Indexes.Models; +using NUnit.Framework; + +namespace Azure.Search.Documents.Tests.Models +{ + public class EdgeNGramTokenFilterTests + { + [Test] + public void CreatesEdgeNGramTokenFilterV2() + { + EdgeNGramTokenFilter sut = new EdgeNGramTokenFilter("test"); + Assert.AreEqual(@"#Microsoft.Azure.Search.EdgeNGramTokenFilterV2", sut.ODataType); + } + + [TestCase(@"#Microsoft.Azure.Search.EdgeNGramTokenFilter")] + [TestCase(@"#Microsoft.Azure.Search.EdgeNGramTokenFilterV2")] + public void EdgeNGramTokenFilterRoundtrips(string odataType) + { + string jsonContent = $@"{{ + ""@odata.type"": ""{odataType}"", + ""name"": ""test"", + ""minGram"": 0, + ""maxGram"": 1, + ""side"": ""front"" +}}"; + + JsonDocument jsonDoc = JsonDocument.Parse(jsonContent); + EdgeNGramTokenFilter sut = TokenFilter.DeserializeTokenFilter(jsonDoc.RootElement) as EdgeNGramTokenFilter; + + Assert.NotNull(sut); + Assert.AreEqual(odataType, sut.ODataType); + Assert.AreEqual("test", sut.Name); + Assert.AreEqual(0, sut.MinGram); + Assert.AreEqual(1, sut.MaxGram); + Assert.AreEqual(EdgeNGramTokenFilterSide.Front, sut.Side); + + using MemoryStream stream = new MemoryStream(); + using (Utf8JsonWriter writer = new Utf8JsonWriter(stream)) + { + ((IUtf8JsonSerializable)sut).Write(writer); + } + + stream.Position = 0; + + jsonDoc = JsonDocument.Parse(stream); + Assert.True(jsonDoc.RootElement.TryGetProperty("@odata.type", out JsonElement odataTypeElem)); + Assert.AreEqual(odataType, odataTypeElem.GetString()); + } + } +} diff --git a/sdk/search/Azure.Search.Documents/tests/Models/KeywordTokenizerTests.cs b/sdk/search/Azure.Search.Documents/tests/Models/KeywordTokenizerTests.cs new file mode 100644 index 000000000000..373aa9813c86 --- /dev/null +++ b/sdk/search/Azure.Search.Documents/tests/Models/KeywordTokenizerTests.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.IO; +using System.Text.Json; +using Azure.Core; +using Azure.Search.Documents.Indexes.Models; +using NUnit.Framework; + +namespace Azure.Search.Documents.Tests.Models +{ + public class KeywordTokenizerTests + { + [Test] + public void CreatesKeywordTokenizerV2() + { + KeywordTokenizer sut = new KeywordTokenizer("test"); + Assert.AreEqual(@"#Microsoft.Azure.Search.KeywordTokenizerV2", sut.ODataType); + } + + [TestCase(@"#Microsoft.Azure.Search.KeywordTokenizer")] + [TestCase(@"#Microsoft.Azure.Search.KeywordTokenizerV2")] + public void KeywordTokenizerRoundtrips(string odataType) + { + string jsonContent = $@"{{ + ""@odata.type"": ""{odataType}"", + ""name"": ""test"", + ""bufferSize"": 1, + ""maxTokenLength"": 1 +}}"; + + JsonDocument jsonDoc = JsonDocument.Parse(jsonContent); + KeywordTokenizer sut = LexicalTokenizer.DeserializeLexicalTokenizer(jsonDoc.RootElement) as KeywordTokenizer; + + Assert.NotNull(sut); + Assert.AreEqual(odataType, sut.ODataType); + Assert.AreEqual("test", sut.Name); + Assert.AreEqual(1, sut.BufferSize); + Assert.AreEqual(1, sut.MaxTokenLength); + + using MemoryStream stream = new MemoryStream(); + using (Utf8JsonWriter writer = new Utf8JsonWriter(stream)) + { + ((IUtf8JsonSerializable)sut).Write(writer); + } + + stream.Position = 0; + + jsonDoc = JsonDocument.Parse(stream); + Assert.True(jsonDoc.RootElement.TryGetProperty("@odata.type", out JsonElement odataTypeElem)); + Assert.AreEqual(odataType, odataTypeElem.GetString()); + } + } +} diff --git a/sdk/search/Azure.Search.Documents/tests/Models/LuceneStandardTokenizerTests.cs b/sdk/search/Azure.Search.Documents/tests/Models/LuceneStandardTokenizerTests.cs new file mode 100644 index 000000000000..97568568aca4 --- /dev/null +++ b/sdk/search/Azure.Search.Documents/tests/Models/LuceneStandardTokenizerTests.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.IO; +using System.Text.Json; +using Azure.Core; +using Azure.Search.Documents.Indexes.Models; +using NUnit.Framework; + +namespace Azure.Search.Documents.Tests.Models +{ + public class LuceneStandardTokenizerTests + { + [Test] + public void CreatesLuceneStandardTokenizerV2() + { + LuceneStandardTokenizer sut = new LuceneStandardTokenizer("test"); + Assert.AreEqual(@"#Microsoft.Azure.Search.StandardTokenizerV2", sut.ODataType); + } + + [TestCase(@"#Microsoft.Azure.Search.StandardTokenizer")] + [TestCase(@"#Microsoft.Azure.Search.StandardTokenizerV2")] + public void LuceneStandardTokenizerRoundtrips(string odataType) + { + string jsonContent = $@"{{ + ""@odata.type"": ""{odataType}"", + ""name"": ""test"", + ""maxTokenLength"": 1 +}}"; + + JsonDocument jsonDoc = JsonDocument.Parse(jsonContent); + LuceneStandardTokenizer sut = LexicalTokenizer.DeserializeLexicalTokenizer(jsonDoc.RootElement) as LuceneStandardTokenizer; + + Assert.NotNull(sut); + Assert.AreEqual(odataType, sut.ODataType); + Assert.AreEqual("test", sut.Name); + Assert.AreEqual(1, sut.MaxTokenLength); + + using MemoryStream stream = new MemoryStream(); + using (Utf8JsonWriter writer = new Utf8JsonWriter(stream)) + { + ((IUtf8JsonSerializable)sut).Write(writer); + } + + stream.Position = 0; + + jsonDoc = JsonDocument.Parse(stream); + Assert.True(jsonDoc.RootElement.TryGetProperty("@odata.type", out JsonElement odataTypeElem)); + Assert.AreEqual(odataType, odataTypeElem.GetString()); + } + } +} diff --git a/sdk/search/Azure.Search.Documents/tests/Models/NGramTokenFilterTests.cs b/sdk/search/Azure.Search.Documents/tests/Models/NGramTokenFilterTests.cs new file mode 100644 index 000000000000..4e33ada6475c --- /dev/null +++ b/sdk/search/Azure.Search.Documents/tests/Models/NGramTokenFilterTests.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.IO; +using System.Text.Json; +using Azure.Core; +using Azure.Search.Documents.Indexes.Models; +using NUnit.Framework; + +namespace Azure.Search.Documents.Tests.Models +{ + public class NGramTokenFilterTests + { + [Test] + public void CreatesNGramTokenFilterV2() + { + NGramTokenFilter sut = new NGramTokenFilter("test"); + Assert.AreEqual(@"#Microsoft.Azure.Search.NGramTokenFilterV2", sut.ODataType); + } + + [TestCase(@"#Microsoft.Azure.Search.NGramTokenFilter")] + [TestCase(@"#Microsoft.Azure.Search.NGramTokenFilterV2")] + public void NGramTokenFilterRoundtrips(string odataType) + { + string jsonContent = $@"{{ + ""@odata.type"": ""{odataType}"", + ""name"": ""test"", + ""minGram"": 0, + ""maxGram"": 1 +}}"; + + JsonDocument jsonDoc = JsonDocument.Parse(jsonContent); + NGramTokenFilter sut = TokenFilter.DeserializeTokenFilter(jsonDoc.RootElement) as NGramTokenFilter; + + Assert.NotNull(sut); + Assert.AreEqual(odataType, sut.ODataType); + Assert.AreEqual("test", sut.Name); + Assert.AreEqual(0, sut.MinGram); + Assert.AreEqual(1, sut.MaxGram); + + using MemoryStream stream = new MemoryStream(); + using (Utf8JsonWriter writer = new Utf8JsonWriter(stream)) + { + ((IUtf8JsonSerializable)sut).Write(writer); + } + + stream.Position = 0; + + jsonDoc = JsonDocument.Parse(stream); + Assert.True(jsonDoc.RootElement.TryGetProperty("@odata.type", out JsonElement odataTypeElem)); + Assert.AreEqual(odataType, odataTypeElem.GetString()); + } + } +} diff --git a/sdk/search/Azure.Search.Documents/tests/Models/PathHierarchyTokenizerTests.cs b/sdk/search/Azure.Search.Documents/tests/Models/PathHierarchyTokenizerTests.cs new file mode 100644 index 000000000000..769100c2c8be --- /dev/null +++ b/sdk/search/Azure.Search.Documents/tests/Models/PathHierarchyTokenizerTests.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.IO; +using System.Text.Json; +using Azure.Core; +using Azure.Search.Documents.Indexes.Models; +using NUnit.Framework; + +namespace Azure.Search.Documents.Tests.Models +{ + public class PathHierarchyTokenizerTests + { + [Test] + public void CreatesPathHierarchyTokenizerV2() + { + PathHierarchyTokenizer sut = new PathHierarchyTokenizer("test"); + Assert.AreEqual(@"#Microsoft.Azure.Search.PathHierarchyTokenizerV2", sut.ODataType); + } + + [Test] + public void PathHierarchyTokenizerRoundtrips() + { + string jsonContent = @"{ + ""@odata.type"": ""#Microsoft.Azure.Search.PathHierarchyTokenizerV2"", + ""name"": ""test"", + ""delimiter"": ""/"", + ""maxTokenLength"": 300, + ""skip"": 0, + ""replacement"": ""/"", + ""reverse"": false +}"; + + JsonDocument jsonDoc = JsonDocument.Parse(jsonContent); + PathHierarchyTokenizer sut = LexicalTokenizer.DeserializeLexicalTokenizer(jsonDoc.RootElement) as PathHierarchyTokenizer; + + Assert.NotNull(sut); + Assert.AreEqual(@"#Microsoft.Azure.Search.PathHierarchyTokenizerV2", sut.ODataType); + Assert.AreEqual("test", sut.Name); + Assert.AreEqual('/', sut.Delimiter); + Assert.AreEqual(300, sut.MaxTokenLength); + Assert.AreEqual(0, sut.NumberOfTokensToSkip); + Assert.AreEqual('/', sut.Replacement); + Assert.AreEqual(false, sut.ReverseTokenOrder); + + using MemoryStream stream = new MemoryStream(); + using (Utf8JsonWriter writer = new Utf8JsonWriter(stream)) + { + ((IUtf8JsonSerializable)sut).Write(writer); + } + + stream.Position = 0; + + jsonDoc = JsonDocument.Parse(stream); + Assert.True(jsonDoc.RootElement.TryGetProperty("@odata.type", out JsonElement odataTypeElem)); + Assert.AreEqual(@"#Microsoft.Azure.Search.PathHierarchyTokenizerV2", odataTypeElem.GetString()); + } + } +}