Example #1
0
        public IEnumerable <Location> Execute(SearchLocationDescriptionQuery query)
        {
            var response = _elasticClient.SearchAsync <Location>(
                s => s.Query(q => q.QueryString(d => d.Query(query.Query)))
                .From((query.Page - 1) * query.PageSize)
                .Size(query.PageSize)).Result;

            return(response.Documents);
        }
        public async Task <Result <IEnumerable <LocationView> > > Search(string query, int page = 1, int pageSize = 5)
        {
            var result = new Result <IEnumerable <LocationView> >();

            try
            {
                var searchQuery = new SearchLocationDescriptionQuery(query, page, pageSize);
                var locations   = _mediator.Execute(searchQuery);
                result.Data = locations.Select(_mapper.Map <LocationView>);
            }
            catch (Exception e)
            {
                result.Error     = e.Message;
                result.IsSuccess = false;
            }
            finally
            {
                _logger.LogInformation($"Location retrieved.");
            }

            return(result);
        }