Add() public method

Adds a new item to the collection of items returned by the search. If the hit represents an existing record it will be combined to the existing hit instead.
public Add ( SearchHit hit ) : void
hit SearchHit the hit to be added or /// combined to a existing hit
return void
Ejemplo n.º 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);
        }
Ejemplo n.º 2
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);
        }
		void AddToResult(SearchResult result, Postings found)
		{
			foreach (Posting posting in found)
			{
				result.Add(new SearchHit(posting.Record));
			}
		}		
Ejemplo n.º 4
0
		public void SetUp()
		{
			_record1 = CreateRecord("Teresa", 43);
			_record2 = CreateRecord("M�rcia", 26);
			_record3 = CreateRecord("Bamboo", 27);

			_result = new SearchResult();
			_result.Add(new SearchHit(_record1));
			_result.Add(new SearchHit(_record2));
			_result.Add(new SearchHit(_record3));
		}
Ejemplo n.º 5
0
		public void TestIntersect()
		{
			SearchResult other = new SearchResult();
			other.Add(new SearchHit(_record3));
			other.Add(new SearchHit(_record1));
			
			AssertSearchHits(_result.Intersect(other), _record1, _record3);

			other = new SearchResult();
			other.Add(new SearchHit(_record2));
			
			AssertSearchHits(_result.Intersect(other), _record2);

			AssertEquals(0, _result.Intersect(new SearchResult()).Count);
			AssertSearchHits(_result.Intersect(_result), _record1, _record2, _record3);
		}
Ejemplo n.º 6
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;
		}
Ejemplo n.º 7
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;
		}