Ejemplo n.º 1
0
        public static Task AllowQueryingAsync(this ISearchIndexManager manager, string indexName, Action <AllowQueryingSearchIndexOptions> configureOptions)
        {
            var options = new AllowQueryingSearchIndexOptions();

            configureOptions(options);

            return(manager.AllowQueryingAsync(indexName, options));
        }
        public async Task AllowQueryingAsync(string indexName, AllowQueryingSearchIndexOptions options)
        {
            var baseUri = GetQueryControlUri(indexName, true);

            Logger.LogInformation($"Trying to allow querying for index with name {indexName} - {baseUri}");

            try
            {
                var result = await _client.PostAsync(baseUri, null, options.CancellationToken).ConfigureAwait(false);

                if (result.StatusCode == HttpStatusCode.NotFound)
                {
                    throw new SearchIndexNotFound(indexName);
                }

                result.EnsureSuccessStatusCode();
            }
            catch (Exception exception)
            {
                Logger.LogError(exception, $"Failed to allow querying for index with name {indexName} - {baseUri}");
                throw;
            }
        }