Esempio n. 1
0
            private Explanation DoExplain(IndexReader reader, int doc)
            {
                Scorer[] valSrcScorers = new Scorer[valSrcWeights.Length];
                for (int i = 0; i < valSrcScorers.Length; i++)
                {
                    valSrcScorers[i] = valSrcWeights[i].Scorer(reader, true, false);
                }
                Explanation subQueryExpl = subQueryWeight.Explain(reader, doc);

                if (!subQueryExpl.IsMatch())
                {
                    return(subQueryExpl);
                }
                // match
                Explanation[] valSrcExpls = new Explanation[valSrcScorers.Length];
                for (int i = 0; i < valSrcScorers.Length; i++)
                {
                    valSrcExpls[i] = valSrcScorers[i].Explain(doc);
                }
                Explanation customExp = Enclosing_Instance.GetCustomScoreProvider(reader).CustomExplain(doc, subQueryExpl, valSrcExpls);
                float       sc        = GetValue() * customExp.GetValue();
                Explanation res       = new ComplexExplanation(true, sc, Enclosing_Instance.ToString() + ", product of:");

                res.AddDetail(customExp);
                res.AddDetail(new Explanation(GetValue(), "queryBoost"));                 // actually using the q boost as q weight (== weight value)
                return(res);
            }
Esempio n. 2
0
        /// <summary>Removes and returns the least scorer of the ScorerDocQueue in log(size)
        /// time.
        /// Should not be used when the queue is empty.
        /// </summary>
        public Scorer Pop()
        {
            // assert size > 0;
            Scorer result = topHSD.scorer;

            PopNoResult();
            return(result);
        }
Esempio n. 3
0
            private float[] vScores;             // reused in score() to avoid allocating this array for each doc

            // constructor
            internal CustomScorer(CustomScoreQuery enclosingInstance, Similarity similarity, IndexReader reader, CustomWeight w, Scorer subQueryScorer, Scorer[] valSrcScorers) : base(similarity)
            {
                InitBlock(enclosingInstance);
                this.weight         = w;
                this.qWeight        = w.GetValue();
                this.subQueryScorer = subQueryScorer;
                this.valSrcScorers  = valSrcScorers;
                this.reader         = reader;
                this.vScores        = new float[valSrcScorers.Length];
                this.provider       = this.Enclosing_Instance.GetCustomScoreProvider(reader);
            }
Esempio n. 4
0
            public override Scorer Scorer(IndexReader reader, bool scoreDocsInOrder, bool topScorer)
            {
                // Pass true for "scoresDocsInOrder", because we
                // require in-order scoring, even if caller does not,
                // since we call advance on the valSrcScorers.  Pass
                // false for "topScorer" because we will not invoke
                // score(Collector) on these scorers:
                Scorer subQueryScorer = subQueryWeight.Scorer(reader, true, false);

                if (subQueryScorer == null)
                {
                    return(null);
                }
                Scorer[] valSrcScorers = new Scorer[valSrcWeights.Length];
                for (int i = 0; i < valSrcScorers.Length; i++)
                {
                    valSrcScorers[i] = valSrcWeights[i].Scorer(reader, true, topScorer);
                }
                return(new CustomScorer(enclosingInstance, similarity, reader, this, subQueryScorer, valSrcScorers));
            }
Esempio n. 5
0
 /// <summary> Adds a Scorer to the ScorerDocQueue in log(size) time if either
 /// the ScorerDocQueue is not full, or not lessThan(scorer, top()).
 /// </summary>
 /// <param name="scorer">
 /// </param>
 /// <returns> true if scorer is added, false otherwise.
 /// </returns>
 public virtual bool Insert(Scorer scorer)
 {
     if (size < maxSize)
     {
         Put(scorer);
         return(true);
     }
     else
     {
         int docNr = scorer.DocID();
         if ((size > 0) && (!(docNr < topHSD.doc)))
         {
             // heap[1] is top()
             heap[1] = new HeapedScorerDoc(this, scorer, docNr);
             DownHeap();
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Esempio n. 6
0
 internal AnonymousClassScorer(Mono.Lucene.Net.Search.Scorer scorer, Mono.Lucene.Net.Search.DocIdSetIterator docIdSetIterator, AnonymousClassWeight enclosingInstance, Mono.Lucene.Net.Search.Similarity Param1) : base(Param1)
 {
     InitBlock(scorer, docIdSetIterator, enclosingInstance);
 }
Esempio n. 7
0
 private void  InitBlock(Mono.Lucene.Net.Search.Scorer scorer, Mono.Lucene.Net.Search.DocIdSetIterator docIdSetIterator, AnonymousClassWeight enclosingInstance)
 {
     this.scorer            = scorer;
     this.docIdSetIterator  = docIdSetIterator;
     this.enclosingInstance = enclosingInstance;
 }
Esempio n. 8
0
			private float[] vScores; // reused in score() to avoid allocating this array for each doc 
			
			// constructor
			internal CustomScorer(CustomScoreQuery enclosingInstance, Similarity similarity, IndexReader reader, CustomWeight w, Scorer subQueryScorer, Scorer[] valSrcScorers):base(similarity)
			{
				InitBlock(enclosingInstance);
				this.weight = w;
				this.qWeight = w.GetValue();
				this.subQueryScorer = subQueryScorer;
				this.valSrcScorers = valSrcScorers;
				this.reader = reader;
				this.vScores = new float[valSrcScorers.Length];
                this.provider = this.Enclosing_Instance.GetCustomScoreProvider(reader);
			}
Esempio n. 9
0
			private Explanation DoExplain(IndexReader reader, int doc)
			{
				Scorer[] valSrcScorers = new Scorer[valSrcWeights.Length];
				for (int i = 0; i < valSrcScorers.Length; i++)
				{
					valSrcScorers[i] = valSrcWeights[i].Scorer(reader, true, false);
				}
				Explanation subQueryExpl = subQueryWeight.Explain(reader, doc);
				if (!subQueryExpl.IsMatch())
				{
					return subQueryExpl;
				}
				// match
				Explanation[] valSrcExpls = new Explanation[valSrcScorers.Length];
				for (int i = 0; i < valSrcScorers.Length; i++)
				{
					valSrcExpls[i] = valSrcScorers[i].Explain(doc);
				}
                Explanation customExp = Enclosing_Instance.GetCustomScoreProvider(reader).CustomExplain(doc, subQueryExpl, valSrcExpls);
				float sc = GetValue() * customExp.GetValue();
				Explanation res = new ComplexExplanation(true, sc, Enclosing_Instance.ToString() + ", product of:");
				res.AddDetail(customExp);
				res.AddDetail(new Explanation(GetValue(), "queryBoost")); // actually using the q boost as q weight (== weight value)
				return res;
			}
Esempio n. 10
0
			public override Scorer Scorer(IndexReader reader, bool scoreDocsInOrder, bool topScorer)
			{
				// Pass true for "scoresDocsInOrder", because we
				// require in-order scoring, even if caller does not,
				// since we call advance on the valSrcScorers.  Pass
				// false for "topScorer" because we will not invoke
				// score(Collector) on these scorers:
				Scorer subQueryScorer = subQueryWeight.Scorer(reader, true, false);
				if (subQueryScorer == null)
				{
					return null;
				}
				Scorer[] valSrcScorers = new Scorer[valSrcWeights.Length];
				for (int i = 0; i < valSrcScorers.Length; i++)
				{
					valSrcScorers[i] = valSrcWeights[i].Scorer(reader, true, topScorer);
				}
				return new CustomScorer(enclosingInstance, similarity, reader, this, subQueryScorer, valSrcScorers);
			}
Esempio n. 11
0
 /// <summary> Adds a Scorer to a ScorerDocQueue in log(size) time.
 /// If one tries to add more Scorers than maxSize
 /// a RuntimeException (ArrayIndexOutOfBound) is thrown.
 /// </summary>
 public void  Put(Scorer scorer)
 {
     size++;
     heap[size] = new HeapedScorerDoc(this, scorer);
     UpHeap();
 }
Esempio n. 12
0
 internal HeapedScorerDoc(ScorerDocQueue enclosingInstance, Scorer scorer, int doc)
 {
     InitBlock(enclosingInstance);
     this.scorer = scorer;
     this.doc    = doc;
 }
Esempio n. 13
0
 internal HeapedScorerDoc(ScorerDocQueue enclosingInstance, Scorer s) : this(enclosingInstance, s, s.DocID())
 {
 }
Esempio n. 14
0
		/// <summary> Adds a Scorer to the ScorerDocQueue in log(size) time if either
		/// the ScorerDocQueue is not full, or not lessThan(scorer, top()).
		/// </summary>
		/// <param name="scorer">
		/// </param>
		/// <returns> true if scorer is added, false otherwise.
		/// </returns>
		public virtual bool Insert(Scorer scorer)
		{
			if (size < maxSize)
			{
				Put(scorer);
				return true;
			}
			else
			{
				int docNr = scorer.DocID();
				if ((size > 0) && (!(docNr < topHSD.doc)))
				{
					// heap[1] is top()
					heap[1] = new HeapedScorerDoc(this, scorer, docNr);
					DownHeap();
					return true;
				}
				else
				{
					return false;
				}
			}
		}
Esempio n. 15
0
		/// <summary> Adds a Scorer to a ScorerDocQueue in log(size) time.
		/// If one tries to add more Scorers than maxSize
		/// a RuntimeException (ArrayIndexOutOfBound) is thrown.
		/// </summary>
		public void  Put(Scorer scorer)
		{
			size++;
			heap[size] = new HeapedScorerDoc(this, scorer);
			UpHeap();
		}
Esempio n. 16
0
			internal HeapedScorerDoc(ScorerDocQueue enclosingInstance, Scorer scorer, int doc)
			{
				InitBlock(enclosingInstance);
				this.scorer = scorer;
				this.doc = doc;
			}
Esempio n. 17
0
			internal HeapedScorerDoc(ScorerDocQueue enclosingInstance, Scorer s):this(enclosingInstance, s, s.DocID())
			{
			}