| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.Collections.Generic; |
| | 6 | | using Azure.Core; |
| | 7 | |
|
| | 8 | | namespace Azure.Search.Documents.Indexes.Models |
| | 9 | | { |
| | 10 | | /// <summary> |
| | 11 | | /// <para> |
| | 12 | | /// Represents a field in an index definition, which describes the name, data type, and search behavior of a field. |
| | 13 | | /// </para> |
| | 14 | | /// <para> |
| | 15 | | /// When creating an index, instead use the <see cref="SimpleField"/>, <see cref="SearchableField"/>, and <see cref= |
| | 16 | | /// </para> |
| | 17 | | /// </summary> |
| | 18 | | [CodeGenModel("Field")] |
| | 19 | | public partial class SearchField |
| | 20 | | { |
| | 21 | | // TODO: Replace constructor and read-only properties when https://github.com/Azure/autorest.csharp/issues/554 i |
| | 22 | |
|
| | 23 | | /// <summary> |
| | 24 | | /// Initializes a new instance of the <see cref="SearchField"/> class. |
| | 25 | | /// </summary> |
| | 26 | | /// <param name="name">The name of the field, which must be unique within the index or parent field.</param> |
| | 27 | | /// <param name="type">The data type of the field.</param> |
| | 28 | | /// <exception cref="ArgumentException"><paramref name="name"/> is an empty string.</exception> |
| | 29 | | /// <exception cref="ArgumentNullException"><paramref name="name"/> is null.</exception> |
| 20310 | 30 | | public SearchField(string name, SearchFieldDataType type) |
| | 31 | | { |
| 20310 | 32 | | Argument.AssertNotNullOrEmpty(name, nameof(name)); |
| | 33 | |
|
| 20310 | 34 | | Name = name; |
| 20310 | 35 | | Type = type; |
| | 36 | |
|
| 20310 | 37 | | Fields = new ChangeTrackingList<SearchField>(); |
| 20310 | 38 | | SynonymMapNames = new ChangeTrackingList<string>(); |
| 20310 | 39 | | } |
| | 40 | |
|
| | 41 | | /// <summary> |
| | 42 | | /// Gets the name of the field. |
| | 43 | | /// </summary> |
| 20459 | 44 | | public string Name { get; } |
| | 45 | |
|
| | 46 | | /// <summary> |
| | 47 | | /// Ge the data type of the field. |
| | 48 | | /// </summary> |
| 1184 | 49 | | public SearchFieldDataType Type { get; } |
| | 50 | |
|
| | 51 | | // TODO: Remove "overrides" for boolean properties when https://github.com/Azure/autorest.csharp/issues/558 is f |
| | 52 | |
|
| | 53 | | /// <summary> |
| | 54 | | /// Gets or sets a value indicating whether the field is full-text searchable. The default is null. |
| | 55 | | /// This means it will undergo analysis such as word-breaking during indexing. |
| | 56 | | /// This property can be true only for <see cref="SearchFieldDataType.String"/> or "Collection(DataType.String)" |
| | 57 | | /// </summary> |
| | 58 | | /// <remarks> |
| | 59 | | /// <para> |
| | 60 | | /// Full-text searches enable the field value "sunny day" to be split into individual terms "sunny" and "day". T |
| | 61 | | /// </para> |
| | 62 | | /// <para> |
| | 63 | | /// This field must be set according to constraints described in the summary, or the server may respond with an |
| | 64 | | /// Instead, consider using the <see cref="SimpleField"/>, <see cref="SearchableField"/>, and <see cref="Complex |
| | 65 | | /// </para> |
| | 66 | | /// </remarks> |
| | 67 | | [CodeGenMember("searchable")] |
| 26776 | 68 | | public bool? IsSearchable { get; set; } |
| | 69 | |
|
| | 70 | | /// <summary> |
| | 71 | | /// Gets or sets a value indicating whether the field can be referenced in <c>$filter</c> queries. The default i |
| | 72 | | /// This property must be null for complex fields, but can be set on simple fields within a complex field. |
| | 73 | | /// </summary> |
| | 74 | | /// <remarks> |
| | 75 | | /// <para> |
| | 76 | | /// Filterable differs from searchable in how strings are handled. Fields of type <see cref="SearchFieldDataType |
| | 77 | | /// For example, if you set such a field <c>f</c> to "sunny day", <c>$filter=f eq 'sunny'</c> will find no match |
| | 78 | | /// </para> |
| | 79 | | /// <para> |
| | 80 | | /// This field must be set according to constraints described in the summary, or the server may respond with an |
| | 81 | | /// Instead, consider using the <see cref="SimpleField"/>, <see cref="SearchableField"/>, and <see cref="Complex |
| | 82 | | /// </para> |
| | 83 | | /// </remarks> |
| | 84 | | [CodeGenMember("filterable")] |
| 23456 | 85 | | public bool? IsFilterable { get; set; } |
| | 86 | |
|
| | 87 | | /// <summary> |
| | 88 | | /// Gets or sets a value indicating whether the field will be returned in a search result. The default is null. |
| | 89 | | /// This property must be true for key fields, and must be null for complex fields. |
| | 90 | | /// </summary> |
| | 91 | | /// <remarks> |
| | 92 | | /// <para> |
| | 93 | | /// You can hide a field from search results if you want to use it only as a filter, for sorting, or for scoring |
| | 94 | | /// This property can also be changed on existing fields and enabling it does not cause an increase in index sto |
| | 95 | | /// </para> |
| | 96 | | /// <para> |
| | 97 | | /// This field must be set according to constraints described in the summary, or the server may respond with an |
| | 98 | | /// Instead, consider using the <see cref="SimpleField"/>, <see cref="SearchableField"/>, and <see cref="Complex |
| | 99 | | /// </para> |
| | 100 | | /// </remarks> |
| | 101 | | public bool? IsHidden |
| | 102 | | { |
| 1186 | 103 | | get => IsRetrievable.HasValue ? !IsRetrievable : null; |
| 21602 | 104 | | set => IsRetrievable = value.HasValue ? !value : null; |
| | 105 | | } |
| | 106 | |
|
| | 107 | | [CodeGenMember("retrievable")] |
| 24582 | 108 | | private bool? IsRetrievable { get; set; } |
| | 109 | |
|
| | 110 | | /// <summary> |
| | 111 | | /// Gets or sets a value indicating whether the field can be referenced in a <c>$orderby</c> expression. The def |
| | 112 | | /// A simple field can be sortable only if it is a single-valued type such as <see cref="SearchFieldDataType.Str |
| | 113 | | /// </summary> |
| | 114 | | /// <remarks> |
| | 115 | | /// This field must be set according to constraints described in the summary, or the server may respond with an |
| | 116 | | /// Instead, consider using the <see cref="SimpleField"/>, <see cref="SearchableField"/>, and <see cref="Complex |
| | 117 | | /// </remarks> |
| | 118 | | [CodeGenMember("sortable")] |
| 23456 | 119 | | public bool? IsSortable { get; set; } |
| | 120 | |
|
| | 121 | | /// <summary> |
| | 122 | | /// Gets or sets a value indicating whether the field can be retrieved in facet queries. The default is null. |
| | 123 | | /// This property must be null for complex fields, but can be set on simple fields within a complex field. |
| | 124 | | /// </summary> |
| | 125 | | /// <remarks> |
| | 126 | | /// <para> |
| | 127 | | /// Facets are used in presentation of search results that include hit counts by categories. |
| | 128 | | /// For example, in a search for digital cameras, facets might include branch, megapixels, price, etc. |
| | 129 | | /// </para> |
| | 130 | | /// <para> |
| | 131 | | /// This field must be set according to constraints described in the summary, or the server may respond with an |
| | 132 | | /// Instead, consider using the <see cref="SimpleField"/>, <see cref="SearchableField"/>, and <see cref="Complex |
| | 133 | | /// </para> |
| | 134 | | /// </remarks> |
| | 135 | | [CodeGenMember("facetable")] |
| 23456 | 136 | | public bool? IsFacetable { get; set; } |
| | 137 | |
|
| | 138 | | /// <summary> |
| | 139 | | /// Gets or sets whether the field is the key field. The default is null. |
| | 140 | | /// A <see cref="SearchIndex"/> must have exactly one key field of type <see cref="SearchFieldDataType.String"/> |
| | 141 | | /// </summary> |
| | 142 | | /// <remarks> |
| | 143 | | /// This field must be set according to constraints described in the summary, or the server may respond with an |
| | 144 | | /// Instead, consider using the <see cref="SimpleField"/>, <see cref="SearchableField"/>, and <see cref="Complex |
| | 145 | | /// </remarks> |
| | 146 | | [CodeGenMember("key")] |
| 23594 | 147 | | public bool? IsKey { get; set; } |
| | 148 | |
|
| | 149 | | /// <summary> |
| | 150 | | /// Gets or sets the name of the analyzer to use for the field. |
| | 151 | | /// This option can be used only with searchable fields and it cannot be set together with either <see cref="Sea |
| | 152 | | /// Once the analyzer is chosen, it cannot be changed for the field. |
| | 153 | | /// Must be null for complex fields. |
| | 154 | | /// </summary> |
| | 155 | | [CodeGenMember("analyzer")] |
| 2738 | 156 | | public LexicalAnalyzerName? AnalyzerName { get; set; } |
| | 157 | |
|
| | 158 | | /// <summary> |
| | 159 | | /// Gets or sets the name of the analyzer used at search time for the field. |
| | 160 | | /// This option can be used only with searchable fields. |
| | 161 | | /// It must be set together with <see cref="IndexAnalyzerName"/> and it cannot be set together with the <see cre |
| | 162 | | /// This property cannot be set to the name of a language analyzer; use the <see cref="AnalyzerName"/> property |
| | 163 | | /// This analyzer can be updated on an existing field. |
| | 164 | | /// Must be null for complex fields. |
| | 165 | | /// </summary> |
| | 166 | | [CodeGenMember("searchAnalyzer")] |
| 1894 | 167 | | public LexicalAnalyzerName? SearchAnalyzerName { get; set; } |
| | 168 | |
|
| | 169 | | /// <summary> |
| | 170 | | /// Gets or sets the name of the analyzer used at indexing time for the field. |
| | 171 | | /// This option can be used only with searchable fields. |
| | 172 | | /// It must be set together with <see cref="SearchAnalyzerName"/> and it cannot be set together with the <see cr |
| | 173 | | /// This property cannot be set to the name of a language analyzer; use the <see cref="AnalyzerName"/> property |
| | 174 | | /// Once the analyzer is chosen, it cannot be changed for the field. |
| | 175 | | /// Must be null for complex fields. </summary> |
| | 176 | | [CodeGenMember("indexAnalyzer")] |
| 1894 | 177 | | public LexicalAnalyzerName? IndexAnalyzerName { get; set; } |
| | 178 | |
|
| | 179 | | // TODO: Remove "overrides" for collection properties when https://github.com/Azure/autorest.csharp/issues/521 i |
| | 180 | |
|
| | 181 | | /// <summary> |
| | 182 | | /// Gets a list of names of synonym maps associated with this field. Only fields where <see cref="IsSearchable"/ |
| | 183 | | /// </summary> |
| | 184 | | [CodeGenMember("synonymMaps")] |
| 1938 | 185 | | public IList<string> SynonymMapNames { get; } |
| | 186 | |
|
| | 187 | | /// <summary> |
| | 188 | | /// Gets a list of nested fields if this field is of type <see cref="SearchFieldDataType.Complex"/> or "Collecti |
| | 189 | | /// </summary> |
| | 190 | | [CodeGenMember("fields")] |
| 33770 | 191 | | public IList<SearchField> Fields { get; } |
| | 192 | |
|
| | 193 | |
|
| | 194 | | /// <inheritdoc/> |
| | 195 | | /// <remarks> |
| | 196 | | /// This always returns "<see cref="Name"/> : <see cref="Type"/>" and is meant for debugging purposes. |
| | 197 | | /// </remarks> |
| 0 | 198 | | public override string ToString() => $"{Name} : {Type}"; |
| | 199 | | } |
| | 200 | | } |