public HashSet <int> GetInvolvedImages() { involvedImages = involvedImages ?? new HashSet <int>(Hits.Select(x => x.Hit.ImageId).Concat(new[] { Query.ImageId })); return(involvedImages); }
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()); }
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)); }
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); }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return(Hits.Select(h => h.Content).GetEnumerator()); }
IEnumerator <ContentItem> IEnumerable <ContentItem> .GetEnumerator() { return(Hits.Select(h => h.Content).GetEnumerator()); }
public override string ToString() { return($"{nameof(Query)}: {Query.ImageId}/{Query.PatchId}, {nameof(Hits)}: {String.Join(";", Hits.Select(x => x.Hit.ImageId).Distinct())}"); }