示例#1
0
        public HashSet <int> GetInvolvedImages()
        {
            involvedImages = involvedImages ??
                             new HashSet <int>(Hits.Select(x => x.Hit.ImageId).Concat(new[] { Query.ImageId }));

            return(involvedImages);
        }
示例#2
0
        public IEnumerable <T> Documents <T>() where T : class
        {
            if (Hits == null || Hits.Count == 0)
            {
                return(Enumerable.Empty <T>());
            }

            return(Hits.Select(hit => hit.Source.As <T>()).ToList());
        }
示例#3
0
        string OffsetHitsToGrid(List <Hit> hits)
        {
            Hits = Hits.OrderBy(h => h.Index).ThenBy(h => h.Skip).ToList();
            var low = Hits.FirstOrDefault().Index;

            var last = Hits.LastOrDefault();
            var high = last.Index;

            high += (last.Term?.Length ?? 1) * last.Skip;

            Hits = Hits.Select(h => new Hit(h.Term, (h.Index - low), h.Start, h.Skip)).ToList();
            low  = low - Start >= 0 ? low - Start : low;
            high = high >= Text.Length ? Text.Length - 1 : high;
            return(Range(Text, low, high));
        }
示例#4
0
        public override JsonObject ToJson()
        {
            var jo = new JsonObject()
                     .Add("total", Total);

            if (MaxScore > 0)
            {
                jo.Add("max_score", MaxScore);
            }

            if (Hits != null)
            {
                var hits = Hits.Select(e => e.ToJson());
                jo.Add("hits", new JsonArray(hits));
            }

            return(jo);
        }
示例#5
0
文件: Result.cs 项目: wrohrbach/n2cms
 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
 {
     return(Hits.Select(h => h.Content).GetEnumerator());
 }
示例#6
0
文件: Result.cs 项目: wrohrbach/n2cms
 IEnumerator <ContentItem> IEnumerable <ContentItem> .GetEnumerator()
 {
     return(Hits.Select(h => h.Content).GetEnumerator());
 }
示例#7
0
 public override string ToString()
 {
     return($"{nameof(Query)}: {Query.ImageId}/{Query.PatchId}, {nameof(Hits)}: {String.Join(";", Hits.Select(x => x.Hit.ImageId).Distinct())}");
 }