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

            return(involvedImages);
        }
Esempio n. 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());
        }
Esempio n. 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));
        }
Esempio n. 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);
        }
Esempio n. 5
0
 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
 {
     return(Hits.Select(h => h.Content).GetEnumerator());
 }
Esempio n. 6
0
 IEnumerator <ContentItem> IEnumerable <ContentItem> .GetEnumerator()
 {
     return(Hits.Select(h => h.Content).GetEnumerator());
 }
Esempio n. 7
0
 public override string ToString()
 {
     return($"{nameof(Query)}: {Query.ImageId}/{Query.PatchId}, {nameof(Hits)}: {String.Join(";", Hits.Select(x => x.Hit.ImageId).Distinct())}");
 }