Beispiel #1
0
        public IEnumerable <StandardProviderSearchResultsItem> GetProvidersByStandardId(string standardId)
        {
            var take = _queryHelper.GetProvidersByStandardTotalAmount(standardId);

            var results =
                _elasticsearchCustomClient.Search <StandardProviderSearchResultsItem>(
                    s =>
                    s.Index(_applicationSettings.ProviderIndexAlias)
                    .From(0)
                    .Sort(sort => sort.Ascending(f => f.Ukprn))
                    .Take(take)
                    .Query(q => q
                           .Terms(t => t
                                  .Field(f => f.StandardCode)
                                  .Terms(standardId))));

            if (results.ApiCall.HttpStatusCode != 200)
            {
                _applicationLogger.LogWarning($"httpStatusCode was {results.ApiCall.HttpStatusCode}");
                throw new ApplicationException("Failed query providers by standard code");
            }

            if (results.Documents.Count > 1)
            {
                _applicationLogger.LogWarning($"found {results.Documents.Count} providers for the standard {standardId}");
            }

            return(results.Documents);
        }