diff --git a/sdk/search/Azure.Search.Documents/README.md b/sdk/search/Azure.Search.Documents/README.md index a713928bfc0f..14374bb53319 100644 --- a/sdk/search/Azure.Search.Documents/README.md +++ b/sdk/search/Azure.Search.Documents/README.md @@ -289,7 +289,7 @@ SearchIndex index = new SearchIndex("hotels") { new SimpleField("hotelId", SearchFieldDataType.String) { IsKey = true, IsFilterable = true, IsSortable = true }, new SearchableField("hotelName") { IsFilterable = true, IsSortable = true }, - new SearchableField("description") { Analyzer = LexicalAnalyzerName.EnLucene }, + new SearchableField("description") { AnalyzerName = LexicalAnalyzerName.EnLucene }, new SearchableField("tags", collection: true) { IsFilterable = true, IsFacetable = true }, new ComplexField("address") { 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 40317f16c024..c6e86d2a7578 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 @@ -1093,17 +1093,17 @@ public ScoringProfile(string name) { } public partial class SearchableField : Azure.Search.Documents.Indexes.Models.SimpleField { public SearchableField(string name, bool collection = false) : base (default(string), default(Azure.Search.Documents.Indexes.Models.SearchFieldDataType)) { } - public Azure.Search.Documents.Indexes.Models.LexicalAnalyzerName? Analyzer { get { throw null; } set { } } - public Azure.Search.Documents.Indexes.Models.LexicalAnalyzerName? IndexAnalyzer { get { throw null; } set { } } - public Azure.Search.Documents.Indexes.Models.LexicalAnalyzerName? SearchAnalyzer { get { throw null; } set { } } - public System.Collections.Generic.IList SynonymMaps { get { throw null; } } + public Azure.Search.Documents.Indexes.Models.LexicalAnalyzerName? AnalyzerName { get { throw null; } set { } } + public Azure.Search.Documents.Indexes.Models.LexicalAnalyzerName? IndexAnalyzerName { get { throw null; } set { } } + public Azure.Search.Documents.Indexes.Models.LexicalAnalyzerName? SearchAnalyzerName { get { throw null; } set { } } + public System.Collections.Generic.IList SynonymMapNames { get { throw null; } } } public partial class SearchField { public SearchField(string name, Azure.Search.Documents.Indexes.Models.SearchFieldDataType type) { } - public Azure.Search.Documents.Indexes.Models.LexicalAnalyzerName? Analyzer { get { throw null; } set { } } + public Azure.Search.Documents.Indexes.Models.LexicalAnalyzerName? AnalyzerName { get { throw null; } set { } } public System.Collections.Generic.IList Fields { get { throw null; } } - public Azure.Search.Documents.Indexes.Models.LexicalAnalyzerName? IndexAnalyzer { get { throw null; } set { } } + public Azure.Search.Documents.Indexes.Models.LexicalAnalyzerName? IndexAnalyzerName { get { throw null; } set { } } public bool? IsFacetable { get { throw null; } set { } } public bool? IsFilterable { get { throw null; } set { } } public bool? IsHidden { get { throw null; } set { } } @@ -1111,8 +1111,8 @@ public SearchField(string name, Azure.Search.Documents.Indexes.Models.SearchFiel public bool? IsSearchable { get { throw null; } set { } } public bool? IsSortable { get { throw null; } set { } } public string Name { get { throw null; } } - public Azure.Search.Documents.Indexes.Models.LexicalAnalyzerName? SearchAnalyzer { get { throw null; } set { } } - public System.Collections.Generic.IList SynonymMaps { get { throw null; } } + public Azure.Search.Documents.Indexes.Models.LexicalAnalyzerName? SearchAnalyzerName { get { throw null; } set { } } + public System.Collections.Generic.IList SynonymMapNames { get { throw null; } } public Azure.Search.Documents.Indexes.Models.SearchFieldDataType Type { get { throw null; } } public override string ToString() { throw null; } } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchField.Serialization.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchField.Serialization.cs index c0ad5aafd4e4..2ebcf8b3468c 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchField.Serialization.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchField.Serialization.cs @@ -53,26 +53,26 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("facetable"); writer.WriteBooleanValue(IsFacetable.Value); } - if (Analyzer != null) + if (AnalyzerName != null) { writer.WritePropertyName("analyzer"); - writer.WriteStringValue(Analyzer.Value.ToString()); + writer.WriteStringValue(AnalyzerName.Value.ToString()); } - if (SearchAnalyzer != null) + if (SearchAnalyzerName != null) { writer.WritePropertyName("searchAnalyzer"); - writer.WriteStringValue(SearchAnalyzer.Value.ToString()); + writer.WriteStringValue(SearchAnalyzerName.Value.ToString()); } - if (IndexAnalyzer != null) + if (IndexAnalyzerName != null) { writer.WritePropertyName("indexAnalyzer"); - writer.WriteStringValue(IndexAnalyzer.Value.ToString()); + writer.WriteStringValue(IndexAnalyzerName.Value.ToString()); } - if (SynonymMaps != null) + if (SynonymMapNames != null) { writer.WritePropertyName("synonymMaps"); writer.WriteStartArray(); - foreach (var item in SynonymMaps) + foreach (var item in SynonymMapNames) { writer.WriteStringValue(item); } diff --git a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchField.cs b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchField.cs index b7b48c77899c..c77084b0b734 100644 --- a/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchField.cs +++ b/sdk/search/Azure.Search.Documents/src/Generated/Models/SearchField.cs @@ -23,12 +23,12 @@ public partial class SearchField /// A value indicating whether to enable the field to be referenced in $filter queries. filterable differs from searchable in how strings are handled. Fields of type Edm.String or Collection(Edm.String) that are filterable do not undergo word-breaking, so comparisons are for exact matches only. For example, if you set such a field f to "sunny day", $filter=f eq 'sunny' will find no matches, but $filter=f eq 'sunny day' will. This property must be null for complex fields. Default is true for simple fields and null for complex fields. /// A value indicating whether to enable the field to be referenced in $orderby expressions. By default Azure Cognitive Search sorts results by score, but in many experiences users will want to sort by fields in the documents. A simple field can be sortable only if it is single-valued (it has a single value in the scope of the parent document). Simple collection fields cannot be sortable, since they are multi-valued. Simple sub-fields of complex collections are also multi-valued, and therefore cannot be sortable. This is true whether it's an immediate parent field, or an ancestor field, that's the complex collection. Complex fields cannot be sortable and the sortable property must be null for such fields. The default for sortable is true for single-valued simple fields, false for multi-valued simple fields, and null for complex fields. /// A value indicating whether to enable the field to be referenced in facet queries. Typically used in a presentation of search results that includes hit count by category (for example, search for digital cameras and see hits by brand, by megapixels, by price, and so on). This property must be null for complex fields. Fields of type Edm.GeographyPoint or Collection(Edm.GeographyPoint) cannot be facetable. Default is true for all other simple fields. - /// The name of the analyzer to use for the field. This option can be used only with searchable fields and it can't be set together with either searchAnalyzer or indexAnalyzer. Once the analyzer is chosen, it cannot be changed for the field. Must be null for complex fields. - /// The name of the analyzer used at search time for the field. This option can be used only with searchable fields. It must be set together with indexAnalyzer and it cannot be set together with the analyzer option. This property cannot be set to the name of a language analyzer; use the analyzer property instead if you need a language analyzer. This analyzer can be updated on an existing field. Must be null for complex fields. - /// The name of the analyzer used at indexing time for the field. This option can be used only with searchable fields. It must be set together with searchAnalyzer and it cannot be set together with the analyzer option. This property cannot be set to the name of a language analyzer; use the analyzer property instead if you need a language analyzer. Once the analyzer is chosen, it cannot be changed for the field. Must be null for complex fields. - /// A list of the names of synonym maps to associate with this field. This option can be used only with searchable fields. Currently only one synonym map per field is supported. Assigning a synonym map to a field ensures that query terms targeting that field are expanded at query-time using the rules in the synonym map. This attribute can be changed on existing fields. Must be null or an empty collection for complex fields. + /// The name of the analyzer to use for the field. This option can be used only with searchable fields and it can't be set together with either searchAnalyzer or indexAnalyzer. Once the analyzer is chosen, it cannot be changed for the field. Must be null for complex fields. + /// The name of the analyzer used at search time for the field. This option can be used only with searchable fields. It must be set together with indexAnalyzer and it cannot be set together with the analyzer option. This property cannot be set to the name of a language analyzer; use the analyzer property instead if you need a language analyzer. This analyzer can be updated on an existing field. Must be null for complex fields. + /// The name of the analyzer used at indexing time for the field. This option can be used only with searchable fields. It must be set together with searchAnalyzer and it cannot be set together with the analyzer option. This property cannot be set to the name of a language analyzer; use the analyzer property instead if you need a language analyzer. Once the analyzer is chosen, it cannot be changed for the field. Must be null for complex fields. + /// A list of the names of synonym maps to associate with this field. This option can be used only with searchable fields. Currently only one synonym map per field is supported. Assigning a synonym map to a field ensures that query terms targeting that field are expanded at query-time using the rules in the synonym map. This attribute can be changed on existing fields. Must be null or an empty collection for complex fields. /// A list of sub-fields if this is a field of type Edm.ComplexType or Collection(Edm.ComplexType). Must be null or empty for simple fields. - internal SearchField(string name, SearchFieldDataType type, bool? isKey, bool? isRetrievable, bool? isSearchable, bool? isFilterable, bool? isSortable, bool? isFacetable, LexicalAnalyzerName? analyzer, LexicalAnalyzerName? searchAnalyzer, LexicalAnalyzerName? indexAnalyzer, IList synonymMaps, IList fields) + internal SearchField(string name, SearchFieldDataType type, bool? isKey, bool? isRetrievable, bool? isSearchable, bool? isFilterable, bool? isSortable, bool? isFacetable, LexicalAnalyzerName? analyzerName, LexicalAnalyzerName? searchAnalyzerName, LexicalAnalyzerName? indexAnalyzerName, IList synonymMapNames, IList fields) { Name = name; Type = type; @@ -38,17 +38,11 @@ internal SearchField(string name, SearchFieldDataType type, bool? isKey, bool? i IsFilterable = isFilterable; IsSortable = isSortable; IsFacetable = isFacetable; - Analyzer = analyzer; - SearchAnalyzer = searchAnalyzer; - IndexAnalyzer = indexAnalyzer; - SynonymMaps = synonymMaps; + AnalyzerName = analyzerName; + SearchAnalyzerName = searchAnalyzerName; + IndexAnalyzerName = indexAnalyzerName; + SynonymMapNames = synonymMapNames; Fields = fields; } - /// The name of the analyzer to use for the field. This option can be used only with searchable fields and it can't be set together with either searchAnalyzer or indexAnalyzer. Once the analyzer is chosen, it cannot be changed for the field. Must be null for complex fields. - public LexicalAnalyzerName? Analyzer { get; set; } - /// The name of the analyzer used at search time for the field. This option can be used only with searchable fields. It must be set together with indexAnalyzer and it cannot be set together with the analyzer option. This property cannot be set to the name of a language analyzer; use the analyzer property instead if you need a language analyzer. This analyzer can be updated on an existing field. Must be null for complex fields. - public LexicalAnalyzerName? SearchAnalyzer { get; set; } - /// The name of the analyzer used at indexing time for the field. This option can be used only with searchable fields. It must be set together with searchAnalyzer and it cannot be set together with the analyzer option. This property cannot be set to the name of a language analyzer; use the analyzer property instead if you need a language analyzer. Once the analyzer is chosen, it cannot be changed for the field. Must be null for complex fields. - public LexicalAnalyzerName? IndexAnalyzer { get; set; } } } diff --git a/sdk/search/Azure.Search.Documents/src/Indexes/Models/SearchField.cs b/sdk/search/Azure.Search.Documents/src/Indexes/Models/SearchField.cs index 5caa8a866cde..cf55743ea6b2 100644 --- a/sdk/search/Azure.Search.Documents/src/Indexes/Models/SearchField.cs +++ b/sdk/search/Azure.Search.Documents/src/Indexes/Models/SearchField.cs @@ -145,13 +145,43 @@ public bool? IsHidden [CodeGenMember("key")] public bool? IsKey { get; set; } + /// + /// Gets or sets the name of the analyzer to use for the field. + /// This option can be used only with searchable fields and it cannot be set together with either or . + /// Once the analyzer is chosen, it cannot be changed for the field. + /// Must be null for complex fields. + /// + [CodeGenMember("analyzer")] + public LexicalAnalyzerName? AnalyzerName { get; set; } + + /// + /// Gets or sets the name of the analyzer used at search time for the field. + /// This option can be used only with searchable fields. + /// It must be set together with and it cannot be set together with the option. + /// This property cannot be set to the name of a language analyzer; use the property instead if you need a language analyzer. + /// This analyzer can be updated on an existing field. + /// Must be null for complex fields. + /// + [CodeGenMember("searchAnalyzer")] + public LexicalAnalyzerName? SearchAnalyzerName { get; set; } + + /// + /// Gets or sets the name of the analyzer used at indexing time for the field. + /// This option can be used only with searchable fields. + /// It must be set together with and it cannot be set together with the option. + /// This property cannot be set to the name of a language analyzer; use the property instead if you need a language analyzer. + /// Once the analyzer is chosen, it cannot be changed for the field. + /// Must be null for complex fields. + [CodeGenMember("indexAnalyzer")] + public LexicalAnalyzerName? IndexAnalyzerName { get; set; } + // TODO: Remove "overrides" for collection properties when https://github.com/Azure/autorest.csharp/issues/521 is fixed. /// /// Gets a list of names of synonym maps associated with this field. Only fields where is true can have associated synonym maps. /// [CodeGenMember("synonymMaps")] - public IList SynonymMaps { get; internal set; } + public IList SynonymMapNames { get; internal set; } /// /// Gets a list of nested fields if this field is of type or "Collection(DataType.Complex)". diff --git a/sdk/search/Azure.Search.Documents/src/Indexes/Models/SearchableField.cs b/sdk/search/Azure.Search.Documents/src/Indexes/Models/SearchableField.cs index 29221fdde93f..4102c7d64e56 100644 --- a/sdk/search/Azure.Search.Documents/src/Indexes/Models/SearchableField.cs +++ b/sdk/search/Azure.Search.Documents/src/Indexes/Models/SearchableField.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq; namespace Azure.Search.Documents.Indexes.Models { @@ -25,22 +24,24 @@ public SearchableField(string name, bool collection = false) : base(name, collec } /// - /// Gets or sets the name of the language analyzer. This property cannot be set when either or are set. + /// Gets or sets the name of the language analyzer. This property cannot be set when either or are set. /// Once the analyzer is chosen, it cannot be changed for the field in the index. /// - public LexicalAnalyzerName? Analyzer { get; set; } + public LexicalAnalyzerName? AnalyzerName { get; set; } /// - /// Gets or sets the name of the language analyzer for searching. This property must be set together with , and cannot be set when is set. + /// Gets or sets the name of the language analyzer for searching. This property must be set together with , and cannot be set when is set. + /// This property cannot be set to the name of a language analyzer; use the property instead if you need a language analyzer. /// Once the analyzer is chosen, it cannot be changed for the field in the index. /// - public LexicalAnalyzerName? SearchAnalyzer { get; set; } + public LexicalAnalyzerName? SearchAnalyzerName { get; set; } /// - /// Gets or sets the name of the language analyzer for indexing. This property must be set together with , and cannot be set when is set. + /// Gets or sets the name of the language analyzer for indexing. This property must be set together with , and cannot be set when is set. + /// This property cannot be set to the name of a language analyzer; use the property instead if you need a language analyzer. /// Once the analyzer is chosen, it cannot be changed for the field in the index. /// - public LexicalAnalyzerName? IndexAnalyzer { get; set; } + public LexicalAnalyzerName? IndexAnalyzerName { get; set; } /// /// Gets a list of names of synonym maps to associate with this field. @@ -50,7 +51,7 @@ public SearchableField(string name, bool collection = false) : base(name, collec /// Assigning a synonym map to a field ensures that query terms targeting that field are expanded at query-time using the rules in the synonym map. /// This attribute can be changed on existing fields. /// - public IList SynonymMaps { get; } = new List(); + public IList SynonymMapNames { get; } = new List(); /// private protected override void Save(SearchField field) @@ -58,13 +59,13 @@ private protected override void Save(SearchField field) base.Save(field); field.IsSearchable = true; - field.Analyzer = Analyzer; - field.SearchAnalyzer = SearchAnalyzer; - field.IndexAnalyzer = IndexAnalyzer; + field.AnalyzerName = AnalyzerName; + field.SearchAnalyzerName = SearchAnalyzerName; + field.IndexAnalyzerName = IndexAnalyzerName; - if (SynonymMaps.Count > 0) + if (SynonymMapNames.Count > 0) { - field.SynonymMaps = SynonymMaps; + field.SynonymMapNames = SynonymMapNames; } } } diff --git a/sdk/search/Azure.Search.Documents/tests/Samples/Readme.cs b/sdk/search/Azure.Search.Documents/tests/Samples/Readme.cs index ba8f65aa0423..7f5a1a0a7fb5 100644 --- a/sdk/search/Azure.Search.Documents/tests/Samples/Readme.cs +++ b/sdk/search/Azure.Search.Documents/tests/Samples/Readme.cs @@ -204,7 +204,7 @@ public async Task CreateIndex() { new SimpleField("hotelId", SearchFieldDataType.String) { IsKey = true, IsFilterable = true, IsSortable = true }, new SearchableField("hotelName") { IsFilterable = true, IsSortable = true }, - new SearchableField("description") { Analyzer = LexicalAnalyzerName.EnLucene }, + new SearchableField("description") { AnalyzerName = LexicalAnalyzerName.EnLucene }, new SearchableField("tags", collection: true) { IsFilterable = true, IsFacetable = true }, new ComplexField("address") { diff --git a/sdk/search/Azure.Search.Documents/tests/SearchIndexClientTests.cs b/sdk/search/Azure.Search.Documents/tests/SearchIndexClientTests.cs index c35122113ec5..678698fb4956 100644 --- a/sdk/search/Azure.Search.Documents/tests/SearchIndexClientTests.cs +++ b/sdk/search/Azure.Search.Documents/tests/SearchIndexClientTests.cs @@ -203,7 +203,7 @@ public async Task UpdateIndex() createdIndex.Fields.Add( new SearchableField("asciiTags", collection: true) { - Analyzer = analyzerName, + AnalyzerName = analyzerName, IsFacetable = true, IsFilterable = true, }); diff --git a/sdk/search/Azure.Search.Documents/tests/Utilities/SearchFieldComparer.cs b/sdk/search/Azure.Search.Documents/tests/Utilities/SearchFieldComparer.cs index c0fd86409335..0bf86576c26a 100644 --- a/sdk/search/Azure.Search.Documents/tests/Utilities/SearchFieldComparer.cs +++ b/sdk/search/Azure.Search.Documents/tests/Utilities/SearchFieldComparer.cs @@ -37,14 +37,14 @@ public bool Equals(SearchField x, SearchField y) x.IsFilterable != y.IsFilterable || x.IsSortable != y.IsSortable || x.IsFacetable != y.IsFacetable || - x.Analyzer != y.Analyzer || - x.SearchAnalyzer != y.SearchAnalyzer || - x.IndexAnalyzer != y.IndexAnalyzer) + x.AnalyzerName != y.AnalyzerName || + x.SearchAnalyzerName != y.SearchAnalyzerName || + x.IndexAnalyzerName != y.IndexAnalyzerName) { return false; } - if (!CollectionComparer.SharedNullOrEmpty.Equals(x.SynonymMaps, y.SynonymMaps)) + if (!CollectionComparer.SharedNullOrEmpty.Equals(x.SynonymMapNames, y.SynonymMapNames)) { return false; } @@ -74,10 +74,10 @@ public int GetHashCode(SearchField obj) builder.Add(obj.IsFilterable); builder.Add(obj.IsSortable); builder.Add(obj.IsFacetable); - builder.Add(obj.Analyzer); - builder.Add(obj.SearchAnalyzer); - builder.Add(obj.IndexAnalyzer); - builder.Add(obj.SynonymMaps, CollectionComparer.Shared); + builder.Add(obj.AnalyzerName); + builder.Add(obj.SearchAnalyzerName); + builder.Add(obj.IndexAnalyzerName); + builder.Add(obj.SynonymMapNames, CollectionComparer.Shared); builder.Add(obj.Fields, SharedFieldsCollection); return builder.ToHashCode(); diff --git a/sdk/search/Azure.Search.Documents/tests/Utilities/SearchResources.Data.cs b/sdk/search/Azure.Search.Documents/tests/Utilities/SearchResources.Data.cs index e9ad8f33927b..261f0ee262f2 100644 --- a/sdk/search/Azure.Search.Documents/tests/Utilities/SearchResources.Data.cs +++ b/sdk/search/Azure.Search.Documents/tests/Utilities/SearchResources.Data.cs @@ -34,8 +34,8 @@ internal static SearchIndex GetHotelIndex(string name) => { new SimpleField("hotelId", SearchFieldDataType.String) { IsKey = true, IsFilterable = true, IsSortable = true, IsFacetable = true }, new SearchableField("hotelName") { IsFilterable = true, IsSortable = true }, - new SearchableField("description") { Analyzer = LexicalAnalyzerName.EnLucene }, - new SearchableField("descriptionFr") { Analyzer = LexicalAnalyzerName.FrLucene }, + new SearchableField("description") { AnalyzerName = LexicalAnalyzerName.EnLucene }, + new SearchableField("descriptionFr") { AnalyzerName = LexicalAnalyzerName.FrLucene }, new SearchableField("category") { IsFilterable = true, IsSortable = true, IsFacetable = true }, new SearchableField("tags", collection: true) { IsFilterable = true, IsFacetable = true }, new SimpleField("parkingIncluded", SearchFieldDataType.Boolean) { IsFilterable = true, IsSortable = true, IsFacetable = true }, @@ -58,8 +58,8 @@ internal static SearchIndex GetHotelIndex(string name) => { Fields = { - new SearchableField("description") { Analyzer = LexicalAnalyzerName.EnLucene }, - new SearchableField("descriptionFr") { Analyzer = LexicalAnalyzerName.FrLucene }, + new SearchableField("description") { AnalyzerName = LexicalAnalyzerName.EnLucene }, + new SearchableField("descriptionFr") { AnalyzerName = LexicalAnalyzerName.FrLucene }, new SearchableField("type") { IsFilterable = true, IsFacetable = true }, new SimpleField("baseRate", SearchFieldDataType.Double) { IsFilterable = true, IsFacetable = true }, new SearchableField("bedOptions") { IsFilterable = true, IsFacetable = true },