示例#1
0
		private int maxDocs = 200; // max to cache
		
		internal Hits(Searcher s, Query q, Filter f)
		{
			query = q;
			searcher = s;
			filter = f;
			GetMoreDocs(50); // retrieve 100 initially
		}
示例#2
0
 public TermWeight(TermQuery enclosingInstance, Searcher searcher)
 {
     InitBlock(enclosingInstance);
     this.searcher = searcher;
 }
示例#3
0
 protected internal override Weight CreateWeight(Searcher searcher)
 {
     return(new TermWeight(this, searcher));
 }
			public TermWeight(TermQuery enclosingInstance, Searcher searcher)
			{
				InitBlock(enclosingInstance);
				this.searcher = searcher;
			}
		/// <summary> Returns a Weight that applies the filter to the enclosed query's Weight.
		/// This is accomplished by overriding the Scorer returned by the Weight.
		/// </summary>
		protected internal override Weight CreateWeight(Searcher searcher)
		{
			Weight weight = query.CreateWeight(searcher);
			return new AnonymousClassWeight(weight, searcher, this);
		}
示例#6
0
			public BooleanWeight(BooleanQuery enclosingInstance, Searcher searcher)
			{
				InitBlock(enclosingInstance);
				this.searcher = searcher;
				for (int i = 0; i < Enclosing_Instance.clauses.Count; i++)
				{
					BooleanClause c = (BooleanClause) Enclosing_Instance.clauses[i];
					weights.Add(c.query.CreateWeight(searcher));
				}
			}
示例#7
0
 /// <summary>Expert: Constructs an appropriate Weight implementation for this query.
 ///
 /// <p>Only implemented by primitive queries, which re-write to themselves.
 /// </summary>
 protected internal virtual Weight CreateWeight(Searcher searcher)
 {
     throw new System.NotSupportedException();
 }
示例#8
0
		/// <summary>Expert: Constructs an initializes a Weight for a top-level query. </summary>
		public virtual Weight Weight(Searcher searcher)
		{
			Query query = searcher.Rewrite(this);
			Weight weight = query.CreateWeight(searcher);
			float sum = weight.SumOfSquaredWeights();
			float norm = GetSimilarity(searcher).QueryNorm(sum);
			weight.Normalize(norm);
			return weight;
		}
示例#9
0
        /// <summary> Returns a Weight that applies the filter to the enclosed query's Weight.
        /// This is accomplished by overriding the Scorer returned by the Weight.
        /// </summary>
        protected internal override Weight CreateWeight(Searcher searcher)
        {
            Weight weight = query.CreateWeight(searcher);

            return(new AnonymousClassWeight(weight, searcher, this));
        }
示例#10
0
		/// <summary>Expert: Returns the Similarity implementation to be used for this query.
		/// Subclasses may override this method to specify their own Similarity
		/// implementation, perhaps one that delegates through that of the Searcher.
		/// By default the Searcher's Similarity implementation is returned.
		/// </summary>
		public virtual Similarity GetSimilarity(Searcher searcher)
		{
			return searcher.GetSimilarity();
		}
示例#11
0
		/// <summary>Expert: Constructs an appropriate Weight implementation for this query.
		/// 
		/// <p>Only implemented by primitive queries, which re-write to themselves.
		/// </summary>
		protected internal virtual Weight CreateWeight(Searcher searcher)
		{
			throw new System.NotSupportedException();
		}
示例#12
0
 public PhraseWeight(PhraseQuery enclosingInstance, Searcher searcher)
 {
     InitBlock(enclosingInstance);
     this.searcher = searcher;
 }
示例#13
0
		/// <summary>Computes a score factor for a phrase.
		/// 
		/// <p>The default implementation sums the {@link #Idf(Term,Searcher)} factor
		/// for each term in the phrase.
		/// 
		/// </summary>
		/// <param name="terms">the terms in the phrase
		/// </param>
		/// <param name="searcher">the document collection being searched
		/// </param>
		/// <returns> a score factor for the phrase
		/// </returns>
		public virtual float Idf(System.Collections.ICollection terms, Searcher searcher)
		{
			float idf = 0.0f;
			System.Collections.IEnumerator i = terms.GetEnumerator();
			while (i.MoveNext())
			{
				idf += Idf((Term) i.Current, searcher);
			}
			return idf;
		}
示例#14
0
		/// <summary>Computes a score factor for a simple term.
		/// 
		/// <p>The default implementation is:<pre>
		/// return idf(searcher.docFreq(term), searcher.maxDoc());
		/// </pre>
		/// 
		/// Note that {@link Searcher#MaxDoc()} is used instead of
		/// {@link Monodoc.Lucene.Net.Index.IndexReader#NumDocs()} because it is proportional to
		/// {@link Searcher#DocFreq(Term)} , i.e., when one is inaccurate,
		/// so is the other, and in the same direction.
		/// 
		/// </summary>
		/// <param name="term">the term in question
		/// </param>
		/// <param name="searcher">the document collection being searched
		/// </param>
		/// <returns> a score factor for the term
		/// </returns>
		public virtual float Idf(Term term, Searcher searcher)
		{
			return Idf(searcher.DocFreq(term), searcher.MaxDoc());
		}
			public PhrasePrefixWeight(PhrasePrefixQuery enclosingInstance, Searcher searcher)
			{
				InitBlock(enclosingInstance);
				this.searcher = searcher;
			}
示例#16
0
 /// <summary>Computes a score factor for a simple term.
 ///
 /// <p>The default implementation is:<pre>
 /// return idf(searcher.docFreq(term), searcher.maxDoc());
 /// </pre>
 ///
 /// Note that {@link Searcher#MaxDoc()} is used instead of
 /// {@link Monodoc.Lucene.Net.Index.IndexReader#NumDocs()} because it is proportional to
 /// {@link Searcher#DocFreq(Term)} , i.e., when one is inaccurate,
 /// so is the other, and in the same direction.
 ///
 /// </summary>
 /// <param name="term">the term in question
 /// </param>
 /// <param name="searcher">the document collection being searched
 /// </param>
 /// <returns> a score factor for the term
 /// </returns>
 public virtual float Idf(Term term, Searcher searcher)
 {
     return(Idf(searcher.DocFreq(term), searcher.MaxDoc()));
 }
		protected internal override Weight CreateWeight(Searcher searcher)
		{
			if (termArrays.Count == 1)
			{
				// optimize one-term case
				Term[] terms = (Term[]) termArrays[0];
				BooleanQuery boq = new BooleanQuery();
				for (int i = 0; i < terms.Length; i++)
				{
					boq.Add(new TermQuery(terms[i]), false, false);
				}
				boq.SetBoost(GetBoost());
				return boq.CreateWeight(searcher);
			}
			return new PhrasePrefixWeight(this, searcher);
		}
		protected internal override Weight CreateWeight(Searcher searcher)
		{
			if (terms.Count == 1)
			{
				// optimize one-term case
				Term term = (Term) terms[0];
				Query termQuery = new TermQuery(term);
				termQuery.SetBoost(GetBoost());
				return termQuery.CreateWeight(searcher);
			}
			return new PhraseWeight(this, searcher);
		}
示例#19
0
		protected internal override Weight CreateWeight(Searcher searcher)
		{
			return new BooleanWeight(this, searcher);
		}
示例#20
0
 /// <summary>Expert: Returns the Similarity implementation to be used for this query.
 /// Subclasses may override this method to specify their own Similarity
 /// implementation, perhaps one that delegates through that of the Searcher.
 /// By default the Searcher's Similarity implementation is returned.
 /// </summary>
 public virtual Similarity GetSimilarity(Searcher searcher)
 {
     return(searcher.GetSimilarity());
 }