| | | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | | 2 | | // Licensed under the MIT License. See License.txt in the project root for |
| | | 3 | | // license information. |
| | | 4 | | |
| | | 5 | | namespace Microsoft.Azure.Search |
| | | 6 | | { |
| | | 7 | | using System; |
| | | 8 | | using System.Collections.Generic; |
| | | 9 | | using System.Linq; |
| | | 10 | | using System.Net; |
| | | 11 | | using System.Net.Http; |
| | | 12 | | using System.Threading; |
| | | 13 | | using System.Threading.Tasks; |
| | | 14 | | using Microsoft.Azure.Search.Common; |
| | | 15 | | using Models; |
| | | 16 | | using Newtonsoft.Json; |
| | | 17 | | using Rest; |
| | | 18 | | using Rest.Azure; |
| | | 19 | | using Serialization; |
| | | 20 | | |
| | | 21 | | internal class DocumentsOperations : IServiceOperations<SearchIndexClient>, IDocumentsOperations |
| | | 22 | | { |
| | 2 | 23 | | internal static readonly string[] SelectAll = new[] { "*" }; |
| | | 24 | | |
| | | 25 | | /// <summary> |
| | | 26 | | /// Initializes a new instance of the DocumentsOperations class. |
| | | 27 | | /// </summary> |
| | | 28 | | /// <param name='client'> |
| | | 29 | | /// Reference to the service client. |
| | | 30 | | /// </param> |
| | 688 | 31 | | internal DocumentsOperations(SearchIndexClient client) |
| | | 32 | | { |
| | 688 | 33 | | Client = client ?? throw new ArgumentNullException("client"); |
| | 688 | 34 | | } |
| | | 35 | | |
| | | 36 | | /// <summary> |
| | | 37 | | /// Gets a reference to the SearchIndexClient |
| | | 38 | | /// </summary> |
| | 2668 | 39 | | public SearchIndexClient Client { get; private set; } |
| | | 40 | | |
| | | 41 | | public async Task<AzureOperationResponse<long>> CountWithHttpMessagesAsync( |
| | | 42 | | SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), |
| | | 43 | | Dictionary<string, List<string>> customHeaders = null, |
| | | 44 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | | 45 | | { |
| | 38 | 46 | | AzureOperationResponse<long?> response = |
| | 38 | 47 | | await Client.DocumentsProxy.CountWithHttpMessagesAsync( |
| | 38 | 48 | | searchRequestOptions, |
| | 38 | 49 | | customHeaders, |
| | 38 | 50 | | cancellationToken).ConfigureAwait(false); |
| | | 51 | | |
| | 38 | 52 | | return new AzureOperationResponse<long>() |
| | 38 | 53 | | { |
| | 38 | 54 | | Body = response.Body.GetValueOrDefault(), |
| | 38 | 55 | | Request = response.Request, |
| | 38 | 56 | | RequestId = response.RequestId, |
| | 38 | 57 | | Response = response.Response |
| | 38 | 58 | | }; |
| | 38 | 59 | | } |
| | | 60 | | |
| | | 61 | | public Task<AzureOperationResponse<AutocompleteResult>> AutocompleteWithHttpMessagesAsync( |
| | | 62 | | string searchText, |
| | | 63 | | string suggesterName, |
| | | 64 | | AutocompleteParameters autocompleteParameters = null, |
| | | 65 | | SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), |
| | | 66 | | Dictionary<string, List<string>> customHeaders = null, |
| | | 67 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | | 68 | | { |
| | 76 | 69 | | if (Client.UseHttpGetForQueries) |
| | | 70 | | { |
| | 38 | 71 | | return Client.DocumentsProxy.AutocompleteGetWithHttpMessagesAsync( |
| | 38 | 72 | | searchText, |
| | 38 | 73 | | suggesterName, |
| | 38 | 74 | | searchRequestOptions, |
| | 38 | 75 | | autocompleteParameters, |
| | 38 | 76 | | customHeaders, |
| | 38 | 77 | | cancellationToken); |
| | | 78 | | } |
| | | 79 | | else |
| | | 80 | | { |
| | 38 | 81 | | return Client.DocumentsProxy.AutocompletePostWithHttpMessagesAsync( |
| | 38 | 82 | | (autocompleteParameters ?? new AutocompleteParameters()).ToRequest(searchText, suggesterName), |
| | 38 | 83 | | searchRequestOptions, |
| | 38 | 84 | | customHeaders, |
| | 38 | 85 | | cancellationToken); |
| | | 86 | | } |
| | | 87 | | } |
| | | 88 | | |
| | | 89 | | public Task<AzureOperationResponse<DocumentSearchResult<Document>>> ContinueSearchWithHttpMessagesAsync( |
| | | 90 | | SearchContinuationToken continuationToken, |
| | | 91 | | SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), |
| | | 92 | | Dictionary<string, List<string>> customHeaders = null, |
| | | 93 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | | 94 | | { |
| | 12 | 95 | | var deserializerSettings = JsonUtility.CreateDocumentDeserializerSettings(Client.DeserializationSettings); |
| | | 96 | | |
| | 12 | 97 | | return DoContinueSearchAsync<Document>( |
| | 12 | 98 | | continuationToken, |
| | 12 | 99 | | searchRequestOptions, |
| | 12 | 100 | | customHeaders, |
| | 12 | 101 | | cancellationToken, |
| | 12 | 102 | | deserializerSettings); |
| | | 103 | | } |
| | | 104 | | |
| | | 105 | | public Task<AzureOperationResponse<DocumentSearchResult<T>>> ContinueSearchWithHttpMessagesAsync<T>( |
| | | 106 | | SearchContinuationToken continuationToken, |
| | | 107 | | SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), |
| | | 108 | | Dictionary<string, List<string>> customHeaders = null, |
| | | 109 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | | 110 | | { |
| | 20 | 111 | | var deserializerSettings = JsonUtility.CreateTypedDeserializerSettings<T>(Client.DeserializationSettings); |
| | | 112 | | |
| | 20 | 113 | | return DoContinueSearchAsync<T>( |
| | 20 | 114 | | continuationToken, |
| | 20 | 115 | | searchRequestOptions, |
| | 20 | 116 | | customHeaders, |
| | 20 | 117 | | cancellationToken, |
| | 20 | 118 | | deserializerSettings); |
| | | 119 | | } |
| | | 120 | | |
| | | 121 | | public Task<AzureOperationResponse<Document>> GetWithHttpMessagesAsync( |
| | | 122 | | string key, |
| | | 123 | | IEnumerable<string> selectedFields, |
| | | 124 | | SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), |
| | | 125 | | Dictionary<string, List<string>> customHeaders = null, |
| | | 126 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | | 127 | | { |
| | 34 | 128 | | JsonSerializerSettings jsonSerializerSettings = |
| | 34 | 129 | | JsonUtility.CreateDocumentDeserializerSettings(Client.DeserializationSettings); |
| | | 130 | | |
| | 34 | 131 | | return Client.DocumentsProxy.GetWithHttpMessagesAsync<Document>( |
| | 34 | 132 | | key, |
| | 34 | 133 | | selectedFields.ToList(), |
| | 34 | 134 | | searchRequestOptions, |
| | 34 | 135 | | EnsureCustomHeaders(customHeaders), |
| | 34 | 136 | | cancellationToken, |
| | 34 | 137 | | responseDeserializerSettings: jsonSerializerSettings); |
| | | 138 | | } |
| | | 139 | | |
| | | 140 | | public Task<AzureOperationResponse<T>> GetWithHttpMessagesAsync<T>( |
| | | 141 | | string key, |
| | | 142 | | IEnumerable<string> selectedFields, |
| | | 143 | | SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), |
| | | 144 | | Dictionary<string, List<string>> customHeaders = null, |
| | | 145 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | | 146 | | { |
| | 46 | 147 | | JsonSerializerSettings jsonSerializerSettings = |
| | 46 | 148 | | JsonUtility.CreateTypedDeserializerSettings<T>(Client.DeserializationSettings); |
| | | 149 | | |
| | 46 | 150 | | return Client.DocumentsProxy.GetWithHttpMessagesAsync<T>( |
| | 46 | 151 | | key, |
| | 46 | 152 | | selectedFields.ToList(), |
| | 46 | 153 | | searchRequestOptions, |
| | 46 | 154 | | EnsureCustomHeaders(customHeaders), |
| | 46 | 155 | | cancellationToken, |
| | 46 | 156 | | responseDeserializerSettings: jsonSerializerSettings); |
| | | 157 | | } |
| | | 158 | | |
| | | 159 | | public Task<AzureOperationResponse<DocumentIndexResult>> IndexWithHttpMessagesAsync( |
| | | 160 | | IndexBatch<Document> batch, |
| | | 161 | | SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), |
| | | 162 | | Dictionary<string, List<string>> customHeaders = null, |
| | | 163 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | | 164 | | { |
| | 40 | 165 | | JsonSerializerSettings jsonSettings = JsonUtility.CreateDocumentSerializerSettings(Client.SerializationSetti |
| | | 166 | | |
| | 40 | 167 | | return DoIndexAsync(batch, searchRequestOptions, customHeaders, jsonSettings, cancellationToken); |
| | | 168 | | } |
| | | 169 | | |
| | | 170 | | public Task<AzureOperationResponse<DocumentIndexResult>> IndexWithHttpMessagesAsync<T>( |
| | | 171 | | IndexBatch<T> batch, |
| | | 172 | | SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), |
| | | 173 | | Dictionary<string, List<string>> customHeaders = null, |
| | | 174 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | | 175 | | { |
| | 406 | 176 | | bool useCamelCase = SerializePropertyNamesAsCamelCaseAttribute.IsDefinedOnType<T>(); |
| | 406 | 177 | | JsonSerializerSettings jsonSettings = JsonUtility.CreateTypedSerializerSettings<T>(Client.SerializationSetti |
| | | 178 | | |
| | 406 | 179 | | return DoIndexAsync(batch, searchRequestOptions, customHeaders, jsonSettings, cancellationToken); |
| | | 180 | | } |
| | | 181 | | |
| | | 182 | | public Task<AzureOperationResponse<DocumentSearchResult<Document>>> SearchWithHttpMessagesAsync( |
| | | 183 | | string searchText, |
| | | 184 | | SearchParameters searchParameters, |
| | | 185 | | SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), |
| | | 186 | | Dictionary<string, List<string>> customHeaders = null, |
| | | 187 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | | 188 | | { |
| | 30 | 189 | | var deserializerSettings = JsonUtility.CreateDocumentDeserializerSettings(Client.DeserializationSettings); |
| | | 190 | | |
| | 30 | 191 | | return DoSearchAsync<Document>( |
| | 30 | 192 | | searchText, |
| | 30 | 193 | | searchParameters, |
| | 30 | 194 | | searchRequestOptions, |
| | 30 | 195 | | customHeaders, |
| | 30 | 196 | | deserializerSettings, |
| | 30 | 197 | | cancellationToken); |
| | | 198 | | } |
| | | 199 | | |
| | | 200 | | public Task<AzureOperationResponse<DocumentSearchResult<T>>> SearchWithHttpMessagesAsync<T>( |
| | | 201 | | string searchText, |
| | | 202 | | SearchParameters searchParameters, |
| | | 203 | | SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), |
| | | 204 | | Dictionary<string, List<string>> customHeaders = null, |
| | | 205 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | | 206 | | { |
| | 112 | 207 | | var deserializerSettings = JsonUtility.CreateTypedDeserializerSettings<T>(Client.DeserializationSettings); |
| | | 208 | | |
| | 112 | 209 | | return DoSearchAsync<T>( |
| | 112 | 210 | | searchText, |
| | 112 | 211 | | searchParameters, |
| | 112 | 212 | | searchRequestOptions, |
| | 112 | 213 | | customHeaders, |
| | 112 | 214 | | deserializerSettings, |
| | 112 | 215 | | cancellationToken); |
| | | 216 | | } |
| | | 217 | | |
| | | 218 | | public Task<AzureOperationResponse<DocumentSuggestResult<Document>>> SuggestWithHttpMessagesAsync( |
| | | 219 | | string searchText, |
| | | 220 | | string suggesterName, |
| | | 221 | | SuggestParameters suggestParameters, |
| | | 222 | | SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), |
| | | 223 | | Dictionary<string, List<string>> customHeaders = null, |
| | | 224 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | | 225 | | { |
| | 16 | 226 | | var deserializerSettings = JsonUtility.CreateDocumentDeserializerSettings(Client.DeserializationSettings); |
| | | 227 | | |
| | 16 | 228 | | return DoSuggestAsync<Document>( |
| | 16 | 229 | | searchText, |
| | 16 | 230 | | suggesterName, |
| | 16 | 231 | | suggestParameters, |
| | 16 | 232 | | searchRequestOptions, |
| | 16 | 233 | | customHeaders, |
| | 16 | 234 | | deserializerSettings, |
| | 16 | 235 | | cancellationToken); |
| | | 236 | | } |
| | | 237 | | |
| | | 238 | | public Task<AzureOperationResponse<DocumentSuggestResult<T>>> SuggestWithHttpMessagesAsync<T>( |
| | | 239 | | string searchText, |
| | | 240 | | string suggesterName, |
| | | 241 | | SuggestParameters suggestParameters, |
| | | 242 | | SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), |
| | | 243 | | Dictionary<string, List<string>> customHeaders = null, |
| | | 244 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | | 245 | | { |
| | 56 | 246 | | var deserializerSettings = JsonUtility.CreateTypedDeserializerSettings<T>(Client.DeserializationSettings); |
| | | 247 | | |
| | 56 | 248 | | return DoSuggestAsync<T>( |
| | 56 | 249 | | searchText, |
| | 56 | 250 | | suggesterName, |
| | 56 | 251 | | suggestParameters, |
| | 56 | 252 | | searchRequestOptions, |
| | 56 | 253 | | customHeaders, |
| | 56 | 254 | | deserializerSettings, |
| | 56 | 255 | | cancellationToken); |
| | | 256 | | } |
| | | 257 | | |
| | | 258 | | private static Dictionary<string, List<string>> EnsureCustomHeaders(Dictionary<string, List<string>> customHeade |
| | | 259 | | { |
| | | 260 | | const string Accept = nameof(Accept); |
| | | 261 | | const string AcceptValue = "application/json;odata.metadata=none"; |
| | | 262 | | |
| | 772 | 263 | | customHeaders = customHeaders ?? new Dictionary<string, List<string>>(); |
| | | 264 | | |
| | 772 | 265 | | if (!customHeaders.ContainsKey(Accept)) |
| | | 266 | | { |
| | 772 | 267 | | customHeaders[Accept] = new List<string>() { AcceptValue }; |
| | | 268 | | } |
| | | 269 | | |
| | 772 | 270 | | return customHeaders; |
| | | 271 | | } |
| | | 272 | | |
| | | 273 | | private async Task<AzureOperationResponse<DocumentIndexResult>> DoIndexAsync<T>( |
| | | 274 | | IndexBatch<T> batch, |
| | | 275 | | SearchRequestOptions searchRequestOptions, |
| | | 276 | | Dictionary<string, List<string>> customHeaders, |
| | | 277 | | JsonSerializerSettings jsonSettings, |
| | | 278 | | CancellationToken cancellationToken) |
| | | 279 | | { |
| | 446 | 280 | | var result = |
| | 446 | 281 | | await Client.DocumentsProxy.IndexWithHttpMessagesAsync( |
| | 446 | 282 | | batch, |
| | 446 | 283 | | searchRequestOptions, |
| | 446 | 284 | | EnsureCustomHeaders(customHeaders), |
| | 446 | 285 | | cancellationToken, |
| | 446 | 286 | | requestSerializerSettings: jsonSettings).ConfigureAwait(false); |
| | | 287 | | |
| | 444 | 288 | | if (result.Response.StatusCode == (HttpStatusCode)207) |
| | | 289 | | { |
| | 8 | 290 | | HttpRequestMessage httpRequest = result.Request; |
| | 8 | 291 | | HttpResponseMessage httpResponse = result.Response; |
| | | 292 | | |
| | | 293 | | // NOTE: It is not possible to read the http request's string content property here, |
| | | 294 | | // via .NET framework's HttpClient, as the Content gets disposed as soon as the request is sent. |
| | | 295 | | // Thus the batch is re-serialized, which is what happens in the IndexWithHttpMessagesAsync() method |
| | | 296 | | // In .NET Core, the Content doesn't get disposed, so it's safe to read the string content here. |
| | | 297 | | #if FullNetFx |
| | | 298 | | string requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(batch, jsonSettings); |
| | | 299 | | #else |
| | 8 | 300 | | string requestContent = await httpRequest.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | | 301 | | #endif |
| | 8 | 302 | | string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | | 303 | | |
| | 8 | 304 | | var exception = |
| | 8 | 305 | | new IndexBatchException(result.Body) |
| | 8 | 306 | | { |
| | 8 | 307 | | Request = new HttpRequestMessageWrapper(httpRequest, requestContent), |
| | 8 | 308 | | Response = new HttpResponseMessageWrapper(httpResponse, responseContent) |
| | 8 | 309 | | }; |
| | | 310 | | |
| | 8 | 311 | | if (httpResponse.Headers.Contains("request-id")) |
| | | 312 | | { |
| | 8 | 313 | | exception.RequestId = httpResponse.Headers.GetValues("request-id").FirstOrDefault(); |
| | | 314 | | } |
| | | 315 | | |
| | 8 | 316 | | result.Dispose(); |
| | 8 | 317 | | throw exception; |
| | | 318 | | } |
| | | 319 | | |
| | 436 | 320 | | return result; |
| | 436 | 321 | | } |
| | | 322 | | |
| | | 323 | | private Task<AzureOperationResponse<DocumentSearchResult<T>>> DoContinueSearchAsync<T>( |
| | | 324 | | SearchContinuationToken continuationToken, |
| | | 325 | | SearchRequestOptions searchRequestOptions, |
| | | 326 | | Dictionary<string, List<string>> customHeaders, |
| | | 327 | | CancellationToken cancellationToken, |
| | | 328 | | JsonSerializerSettings deserializerSettings) |
| | | 329 | | { |
| | | 330 | | // Validate |
| | 32 | 331 | | if (Client.ApiVersion == null) |
| | | 332 | | { |
| | 0 | 333 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | | 334 | | } |
| | | 335 | | |
| | 32 | 336 | | Throw.IfArgumentNull(continuationToken, nameof(continuationToken)); |
| | | 337 | | |
| | 32 | 338 | | Guid? clientRequestId = searchRequestOptions?.ClientRequestId; |
| | | 339 | | |
| | | 340 | | // Tracing |
| | 32 | 341 | | bool shouldTrace = ServiceClientTracing.IsEnabled; |
| | 32 | 342 | | string invocationId = null; |
| | 32 | 343 | | if (shouldTrace) |
| | | 344 | | { |
| | 0 | 345 | | invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| | 0 | 346 | | var tracingParameters = new Dictionary<string, object> |
| | 0 | 347 | | { |
| | 0 | 348 | | ["continuationToken"] = continuationToken, |
| | 0 | 349 | | ["clientRequestId"] = clientRequestId, |
| | 0 | 350 | | ["cancellationToken"] = cancellationToken |
| | 0 | 351 | | }; |
| | | 352 | | |
| | 0 | 353 | | ServiceClientTracing.Enter(invocationId, this, "ContinueSearch", tracingParameters); |
| | | 354 | | } |
| | | 355 | | |
| | 32 | 356 | | bool useGet = continuationToken.NextPageParameters == null; |
| | 32 | 357 | | if (useGet) |
| | | 358 | | { |
| | 16 | 359 | | return Client.DocumentsProxy.ContinueSearchGetWithHttpMessagesAsync<T>( |
| | 16 | 360 | | continuationToken.NextLink, |
| | 16 | 361 | | clientRequestId, |
| | 16 | 362 | | EnsureCustomHeaders(customHeaders), |
| | 16 | 363 | | shouldTrace, |
| | 16 | 364 | | invocationId, |
| | 16 | 365 | | cancellationToken, |
| | 16 | 366 | | responseDeserializerSettings: deserializerSettings); |
| | | 367 | | } |
| | | 368 | | else |
| | | 369 | | { |
| | 16 | 370 | | return Client.DocumentsProxy.ContinueSearchPostWithHttpMessagesAsync<T>( |
| | 16 | 371 | | continuationToken.NextLink, |
| | 16 | 372 | | continuationToken.NextPageParameters, |
| | 16 | 373 | | clientRequestId, |
| | 16 | 374 | | EnsureCustomHeaders(customHeaders), |
| | 16 | 375 | | shouldTrace, |
| | 16 | 376 | | invocationId, |
| | 16 | 377 | | cancellationToken, |
| | 16 | 378 | | responseDeserializerSettings: deserializerSettings); |
| | | 379 | | } |
| | | 380 | | } |
| | | 381 | | |
| | | 382 | | private Task<AzureOperationResponse<DocumentSearchResult<T>>> DoSearchAsync<T>( |
| | | 383 | | string searchText, |
| | | 384 | | SearchParameters searchParameters, |
| | | 385 | | SearchRequestOptions searchRequestOptions, |
| | | 386 | | Dictionary<string, List<string>> customHeaders, |
| | | 387 | | JsonSerializerSettings deserializerSettings, |
| | | 388 | | CancellationToken cancellationToken) |
| | | 389 | | { |
| | 142 | 390 | | searchText = searchText ?? "*"; |
| | | 391 | | |
| | 142 | 392 | | if (Client.UseHttpGetForQueries) |
| | | 393 | | { |
| | 56 | 394 | | return Client.DocumentsProxy.SearchGetWithHttpMessagesAsync<T>( |
| | 56 | 395 | | searchText, |
| | 56 | 396 | | searchParameters, |
| | 56 | 397 | | searchRequestOptions, |
| | 56 | 398 | | EnsureCustomHeaders(customHeaders), |
| | 56 | 399 | | cancellationToken, |
| | 56 | 400 | | responseDeserializerSettings: deserializerSettings); |
| | | 401 | | } |
| | | 402 | | else |
| | | 403 | | { |
| | 86 | 404 | | return Client.DocumentsProxy.SearchPostWithHttpMessagesAsync<T>( |
| | 86 | 405 | | (searchParameters ?? new SearchParameters()).ToRequest(searchText), |
| | 86 | 406 | | searchRequestOptions, |
| | 86 | 407 | | EnsureCustomHeaders(customHeaders), |
| | 86 | 408 | | cancellationToken, |
| | 86 | 409 | | responseDeserializerSettings: deserializerSettings); |
| | | 410 | | } |
| | | 411 | | } |
| | | 412 | | |
| | | 413 | | private Task<AzureOperationResponse<DocumentSuggestResult<T>>> DoSuggestAsync<T>( |
| | | 414 | | string searchText, |
| | | 415 | | string suggesterName, |
| | | 416 | | SuggestParameters suggestParameters, |
| | | 417 | | SearchRequestOptions searchRequestOptions, |
| | | 418 | | Dictionary<string, List<string>> customHeaders, |
| | | 419 | | JsonSerializerSettings deserializerSettings, |
| | | 420 | | CancellationToken cancellationToken) |
| | | 421 | | { |
| | 72 | 422 | | suggestParameters = suggestParameters ?? new SuggestParameters(); |
| | | 423 | | |
| | 72 | 424 | | if (Client.UseHttpGetForQueries) |
| | | 425 | | { |
| | 30 | 426 | | return Client.DocumentsProxy.SuggestGetWithHttpMessagesAsync<T>( |
| | 30 | 427 | | searchText, |
| | 30 | 428 | | suggesterName, |
| | 30 | 429 | | suggestParameters.EnsureSelect(), |
| | 30 | 430 | | searchRequestOptions, |
| | 30 | 431 | | EnsureCustomHeaders(customHeaders), |
| | 30 | 432 | | cancellationToken, |
| | 30 | 433 | | responseDeserializerSettings: deserializerSettings); |
| | | 434 | | } |
| | | 435 | | else |
| | | 436 | | { |
| | 42 | 437 | | return Client.DocumentsProxy.SuggestPostWithHttpMessagesAsync<T>( |
| | 42 | 438 | | suggestParameters.ToRequest(searchText, suggesterName), |
| | 42 | 439 | | searchRequestOptions, |
| | 42 | 440 | | EnsureCustomHeaders(customHeaders), |
| | 42 | 441 | | cancellationToken, |
| | 42 | 442 | | responseDeserializerSettings: deserializerSettings); |
| | | 443 | | } |
| | | 444 | | } |
| | | 445 | | } |
| | | 446 | | } |