public async Task <int> GetResourceIdFromCallNumber(string callNumber) { var searchParams = new SearchOptions { Query = callNumber }; var searchEngine = new ArchivesSpaceSearch(_siteServiceHandler); var searchResults = await searchEngine.ResourceSearchAsync(searchParams); if (searchResults.TotalHits < 1) { return(0); } return(searchResults.Results.First().IdStripped); }
public async Task <HttpResponseMessage> Get(string repo = "", string type = "", string q = "") { //Type is maintained for signature consistency but is not used var reqId = Guid.NewGuid().ToString("D"); var sw = new Stopwatch(); sw.Start(); _logger.Trace("Request for URI [ {0} ] received and assigned ID [ {1} ]", Request.RequestUri, reqId); if (repo == "") { repo = ASpace_Aeon_Middleware.Configuration.DefaultSite; } var activeService = await _serviceHandler.GetArchivesSpaceServiceAsync(repo); var searchEngine = new ArchivesSpaceSearch(activeService); var searchOptions = new SearchOptions { Query = q //note this is not scrubbed for stopwords since the SOLR index will handle that }; if (String.IsNullOrWhiteSpace(q)) { _logger.Trace("Request [ {0} ] finished in [ {1} ] ms", reqId, sw.ElapsedMilliseconds); return(Request.CreateResponse(HttpStatusCode.OK)); } var result = await searchEngine.ResourceSearchAsync(searchOptions, false); //since this is a quick search we only want page one of search results if (result.TotalHits < 0) { _logger.Trace("Request [ {0} ] finished in [ {1} ] ms", reqId, sw.ElapsedMilliseconds); return(Request.CreateResponse(HttpStatusCode.OK)); } var formattedResult = ResultsToPipeSeparatedFormat(result.Results, q); _logger.Trace("Request [ {0} ] finished in [ {1} ] ms", reqId, sw.ElapsedMilliseconds); return(Request.CreateResponse(HttpStatusCode.OK, formattedResult, "text/plain")); }