public static Task CreateAsync(this IQueryIndexes queryIndexes, string bucketName, string indexName, IEnumerable <string> fields, Action <CreateQueryIndexOptions> configureOptions) { var options = new CreateQueryIndexOptions(); configureOptions(options); return(queryIndexes.CreateAsync(bucketName, indexName, fields, options)); }
public async Task CreateAsync(string bucketName, string indexName, IEnumerable <string> fields, CreateQueryIndexOptions options) { Logger.LogInformation($"Attempting to create query index {indexName} on bucket {bucketName}"); try { var statement = $"CREATE INDEX {indexName} ON {bucketName}({string.Join(",", fields)}) USING GSI WITH {{\"defer_build\":{options.Deferred}}};"; await _queryClient.QueryAsync <dynamic>(statement, queryOptions => queryOptions.WithCancellationToken(options.CancellationToken) ); } catch (Exception exception) { Logger.LogError(exception, $"Error trying to create query index {indexName} on {bucketName}"); throw; } }