Ejemplo n.º 1
0
        public static Task <IEnumerable <SearchIndex> > GetAllIndexesAsync(this ISearchIndexManager manager, Action <GetAllSearchIndexesOptions> configureOptions)
        {
            var options = new GetAllSearchIndexesOptions();

            configureOptions(options);

            return(manager.GetAllIndexesAsync(options));
        }
        public async Task <IEnumerable <SearchIndex> > GetAllIndexesAsync(GetAllSearchIndexesOptions options)
        {
            var baseUri = GetIndexUri();

            Logger.LogInformation($"Trying to get all indexes - {baseUri}");

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

                result.EnsureSuccessStatusCode();

                var json = JObject.Parse(await result.Content.ReadAsStringAsync().ConfigureAwait(false));
                return(json["indexDefs"]["indexDefs"].ToObject <Dictionary <string, SearchIndex> >().Values);
            }
            catch (Exception exception)
            {
                Logger.LogError(exception, $"Failed to get all indexes - {baseUri}");
                throw;
            }
        }