コード例 #1
0
        /// <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("records/" + r.Id).Concat(titleNLites.GetFragments("records/" + r.Id))
                                               let abstractFragments                         = abstractLites.GetFragments("records/" + r.Id).Concat(abstractNLites.GetFragments("records/" + r.Id))
                                                                                   let title = titleFragments.Select(f => f.TruncateNicely(200)).FirstOrDefault()
                                                                                               ?? r.Gemini.Title.TruncateNicely(200)
                                                                                               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      = 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(),
                //.OrderBy(k => k.Vocab != "http://vocab.jncc.gov.uk/jncc-broad-category") // show first
                //.ThenBy(k => k.Vocab.IsBlank())
                //.ThenBy(k => k.Vocab).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.DurationMilliseconds,
                Query = input
            });
        }
コード例 #2
0
        /// <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
            });
        }