public static Task UpsertIndexAsync(this ISearchIndexManager manager, SearchIndex indexDefinition, Action <UpsertSearchIndexOptions> configureOptions) { var options = new UpsertSearchIndexOptions(); configureOptions(options); return(manager.UpsertIndexAsync(indexDefinition, options)); }
public async Task UpsertIndexAsync(SearchIndex indexDefinition, UpsertSearchIndexOptions options) { var baseUri = GetIndexUri(indexDefinition.Name); Logger.LogInformation($"Trying to upsert index with name {indexDefinition.Name} - {baseUri}"); try { var json = JsonConvert.SerializeObject(indexDefinition, Formatting.None); var content = new StringContent(json, Encoding.UTF8, MediaType.Json); var result = await _client.PutAsync(baseUri, content, options.CancellationToken).ConfigureAwait(false); result.EnsureSuccessStatusCode(); } catch (Exception exception) { Logger.LogError(exception, $"Failed to upsert index with name {indexDefinition.Name} - {baseUri}"); throw; } }
public async Task UpsertIndexAsync(SearchIndex indexDefinition, UpsertSearchIndexOptions?options = null) { options ??= UpsertSearchIndexOptions.Default; var baseUri = GetIndexUri(indexDefinition.Name); _logger.LogInformation("Trying to upsert index with name {indexDefinition.Name} - {baseUri}", _redactor.MetaData(indexDefinition.Name), _redactor.SystemData(baseUri)); try { var json = JsonConvert.SerializeObject(indexDefinition, Formatting.None); var content = new StringContent(json, Encoding.UTF8, MediaType.Json); var result = await _client.PutAsync(baseUri, content, options.TokenValue).ConfigureAwait(false); result.EnsureSuccessStatusCode(); } catch (Exception exception) { _logger.LogError(exception, "Failed to upsert index with name {indexDefinition.Name} - {baseUri}", _redactor.MetaData(indexDefinition.Name), _redactor.SystemData(baseUri)); throw; } }
public static Task UpsertIndexAsync(this ISearchIndexManager manager, SearchIndex indexDefinition) { return(manager.UpsertIndexAsync(indexDefinition, UpsertSearchIndexOptions.Default)); }