public async Task <ServiceBaseResult <SearchOperationStatus, IReadOnlyCollection <TDocument> > > Search(string query, int page, int pageSize, params Expression <Func <TDocument, object> >[] fields) { if (!SearchValidator.ValidateSearchRequest(query)) { return(new ServiceBaseResult <SearchOperationStatus, IReadOnlyCollection <TDocument> >(SearchOperationStatus.IncorrectRequest, SearchOperationStatus.IncorrectRequest.GetDescription())); } var searchResult = await _elasticClient.SearchAsync <TDocument>(s => s .From((page - 1) * pageSize) .Size(pageSize) .Query(qry => qry.QueryString(q => q.Fields(f => f.Fields(fields)).Query("*" + query + "*")) )); if (!searchResult.Documents.Any()) { return(new ServiceBaseResult <SearchOperationStatus, IReadOnlyCollection <TDocument> >(SearchOperationStatus.NotFound, SearchOperationStatus.NotFound.GetDescription())); } return(new ServiceBaseResult <SearchOperationStatus, IReadOnlyCollection <TDocument> >(SearchOperationStatus.Success, SearchOperationStatus.Success.GetDescription(), searchResult.Documents)); }
public SearchInputManualMapper( StopRepository stopRepository, SearchValidator searchValidator) { _stopRepository = stopRepository; _searchValidator = searchValidator; }
public SearchManager( IConnectionSearchEngine connectionSearchEngine, IGraphFactory <StopGraph> graphGenerator, FastestPathResolver fastestPathResolver, FastestPathDescriptionWriter fastestPathDescriptionWriter, SearchValidator searchValidator, SearchInputManualMapper searchInputManualMapper, LineRepository lineRepository, StopRepository stopRepository) { _connectionSearchEngine = connectionSearchEngine; _graphGenerator = graphGenerator; _fastestPathDescriptionWriter = fastestPathDescriptionWriter; _searchValidator = searchValidator; _searchInputManualMapper = searchInputManualMapper; _lineRepository = lineRepository; _stopRepository = stopRepository; _fastestPathResolver = fastestPathResolver; }