コード例 #1
0
		/// <summary>
		/// Build a new SearchResult object including
		/// only those elements for which the 
		/// filter returns true.
		/// </summary>
		/// <param name="filter">filter</param>
		/// <returns>a new SearchResult containing all the elements for which 
		/// <see cref="ISearchHitFilter.Test"/> returned true</returns>
		public SearchResult Filter(ISearchHitFilter filter)
		{
			SearchResult result = new SearchResult();
			foreach (SearchHit hit in _hits)
			{
				if (filter.Test(hit))
				{
					result.Add(hit);
				}
			}			
			return result;
		}
コード例 #2
0
		void AddToResult(SearchResult result, Postings found)
		{
			foreach (Posting posting in found)
			{
				result.Add(new SearchHit(posting.Record));
			}
		}		
コード例 #3
0
		/// <summary>
		/// Set intersection operation. Creates
		/// a new SearchResult with all the records
		/// that exist in both SearchResult objects.
		/// </summary>
		/// <param name="other"></param>
		/// <returns>a SearchResult representing the
		/// intersection between the this and other objects
		/// </returns>
		/// <remarks>all the SearchHit objects in
		/// the resulting SearchResult are clones from
		/// the original ones combined to the ones in
		/// other</remarks>
		public SearchResult Intersect(SearchResult other)
		{
			SearchResult result = new SearchResult();
			foreach (SearchHit hit in _hits)
			{
				SearchHit otherHit = other.FindSearchHit(hit.Record);
				if (null != otherHit)
				{
					SearchHit resultingHit = hit.Clone();
					resultingHit.Combine(otherHit);
					result.Add(resultingHit);
				}
			}
			return result;
		}