public static IList <DocumentScore> Reduce(this IList <QueryContext> query) { var first = query[0].Scores; for (int i = 1; i < query.Count; i++) { var term = query[i]; var other = term.Scores; if (term.Query.Or) { first = DocumentScore.CombineOr(first, other); } else if (term.Query.Not) { first = DocumentScore.Not(first, other); } else // And { first = DocumentScore.CombineAnd(first, other); } } return(first); }
public IEnumerable <DocumentScore> Reduce() { var first = Scored; if (_queries != null) { foreach (var child in _queries) { var other = child.Reduce(); if (child.And) { first = DocumentScore.CombineAnd(first, other).ToList(); } else if (child.Not) { first = DocumentScore.Not(first, other).ToList(); } else // Or { first = DocumentScore.CombineOr(first, other).ToList(); } } } return(first); }
public IEnumerable <DocumentScore> Reduce() { var first = Scored.ToList(); foreach (var child in Children) { var other = child.Reduce().ToList(); if (child.And) { first = DocumentScore.CombineAnd(first, other).ToList(); } else if (child.Not) { var dic = first.ToDictionary(x => x.DocumentId); foreach (var posting in other) { DocumentScore exists; if (dic.TryGetValue(posting.DocumentId, out exists)) { first.Remove(exists); } } } else // Or { first = DocumentScore.CombineOr(first, other).ToList(); } } return(first); }