/// <summary> /// Returns search entries /// </summary> public abstract Task <IEnumerable <SimpleSearchMetadata> > Search(string searchTerm, SearchFilter filters, int skip, int take, CancellationToken cancellationToken);
public override Task <IEnumerable <Newtonsoft.Json.Linq.JObject> > Search(string searchTerm, SearchFilter filters, int skip, int take, CancellationToken cancellationToken) { // should not be called throw new NotImplementedException(); }
public async override Task <IEnumerable <JObject> > Search(string searchTerm, SearchFilter filters, int skip, int take, CancellationToken cancellationToken) { // Get the search service URL from the service cancellationToken.ThrowIfCancellationRequested(); var searchService = await GetServiceUri(ServiceUris.SearchQueryService); if (String.IsNullOrEmpty(searchService)) { throw new NuGetProtocolException(Strings.Protocol_MissingSearchService); } cancellationToken.ThrowIfCancellationRequested(); // Construct the query var queryUrl = new UriBuilder(searchService); string queryString = "q=" + searchTerm + "&skip=" + skip.ToString() + "&take=" + take.ToString() + "&includePrerelease=" + filters.IncludePrerelease.ToString().ToLowerInvariant(); string frameworks = String.Join("&", filters.SupportedFrameworks.Select( fx => "supportedFramework=" + fx)); if (!String.IsNullOrEmpty(frameworks)) { queryString += "&" + frameworks; } queryUrl.Query = queryString; // Execute the query! Bypass the cache for now NuGetTraceSources.V3SourceRepository.Info( "searching", "Executing Query: {0}", queryUrl.ToString()); var results = await _client.GetFile(queryUrl.Uri); cancellationToken.ThrowIfCancellationRequested(); if (results == null) { NuGetTraceSources.V3SourceRepository.Warning( "results_invalid", "Recieved unexpected results from {0}!", queryUrl.ToString()); return(Enumerable.Empty <JObject>()); } var data = results.Value <JArray>("data"); if (data == null) { NuGetTraceSources.V3SourceRepository.Warning( "results_invalid", "Recieved invalid results from {0}!", queryUrl.ToString()); return(Enumerable.Empty <JObject>()); } NuGetTraceSources.V3SourceRepository.Verbose( "results_received", "Received {1} hits from {0}", queryUrl.ToString(), data.Count); // Resolve all the objects List <JObject> outputs = new List <JObject>(take); foreach (var result in data.Take(take).Cast <JObject>()) { var output = await ProcessSearchResult(cancellationToken, result); if (output != null) { outputs.Add(output); } } return(outputs); }
public override async Task <IEnumerable <Newtonsoft.Json.Linq.JObject> > Search(string searchTerm, SearchFilter filters, int skip, int take, CancellationToken cancellationToken) { await DetectVersionWhenNeccessary(); return(await _repo.Search(searchTerm, filters, skip, take, cancellationToken)); }