public async Task <List <LocationResponse> > Handle(SearchLocationsQuery request, CancellationToken cancellationToken) { var locations = await _locationRepository.SearchLocations(request); return(locations == null ? null : _mapper.Map(locations)); }
public async Task <List <Location> > SearchLocations(SearchLocationsQuery locationQuery) { var client = _elasticSearchClient.CreateElasticClient(_elasticsearchConfig.Value.Url); var locationsResponse = await client.SearchAsync <Location>(far => far.Index(_elasticsearchConfig.Value.LocationIndex) .Query(q => q .QueryString(qs => qs.Query($"{locationQuery.LocationSearch.ToLower()}*").AnalyzeWildcard(true))) ); return(locationsResponse.Documents?.Select(loc => new Location { Region = loc.Region, Country = loc.Country }).ToList()); }