/// <summary> /// A query for the Google-style search results page. /// </summary> public SearchOutputModel Search(RecordQueryInputModel input) { // materializing the query will populate our stats var results = from r in Query(input).ToList() let titleFragments = titleLites.GetFragments(r.Id).Concat(titleNLites.GetFragments(r.Id)) let abstractFragments = abstractLites.GetFragments(r.Id).Concat(abstractNLites.GetFragments(r.Id)) let title = titleFragments.FirstOrDefault() ?? r.Gemini.Title let snippet = abstractFragments.Select(f => f.TruncateNicely(200)).FirstOrDefault() ?? r.Gemini.Abstract.TruncateNicely(200) let format = DataFormatQueries.GetDataFormatInfo(r.Gemini.DataFormat) select new ResultOutputModel { Id = Helpers.RemoveCollection(r.Id), Title = title, // could be better; always want the whole title, highlighted Snippet = snippet, Format = new FormatOutputModel { Group = format.Group, Glyph = format.Glyph, Name = format.Name, }, Keywords = MakeKeywordOutputModelList(r.Gemini.Keywords).ToList(), TopCopy = r.TopCopy, Date = r.Gemini.DatasetReferenceDate, ResourceType = r.Gemini.ResourceType.FirstCharToUpper(), Box = r.Gemini.BoundingBox, }; return(new SearchOutputModel { Total = stats.TotalResults, Results = results.ToList(), Speed = stats.DurationInMs, Query = input }); }