Пример #1
0
        internal ExactPhraseScorer(Weight weight, PhraseQuery.PostingsAndFreq[] postings, Similarity.SimScorer docScorer)
            : base(weight)
        {
            this.DocScorer = docScorer;

            ChunkStates = new ChunkState[postings.Length];

            EndMinus1 = postings.Length - 1;

            // min(cost)
            Cost_Renamed = postings[0].Postings.Cost();

            for (int i = 0; i < postings.Length; i++)
            {
                // Coarse optimization: advance(target) is fairly
                // costly, so, if the relative freq of the 2nd
                // rarest term is not that much (> 1/5th) rarer than
                // the first term, then we just use .nextDoc() when
                // ANDing.  this buys ~15% gain for phrases where
                // freq of rarest 2 terms is close:
                bool useAdvance = postings[i].DocFreq > 5 * postings[0].DocFreq;
                ChunkStates[i] = new ChunkState(postings[i].Postings, -postings[i].Position, useAdvance);
                if (i > 0 && postings[i].Postings.NextDoc() == DocIdSetIterator.NO_MORE_DOCS)
                {
                    NoDocs = true;
                    return;
                }
            }
        }
Пример #2
0
        protected internal SpanScorer(Spans spans, Weight weight, Similarity.SimScorer docScorer)
            : base(weight)
        {
            this.m_docScorer = docScorer;
            this.m_spans     = spans;

            m_doc  = -1;
            m_more = spans.Next();
        }
Пример #3
0
        protected internal SpanScorer(Spans spans, Weight weight, Similarity.SimScorer docScorer)
            : base(weight)
        {
            this.DocScorer = docScorer;
            this.Spans = spans;

            Doc = -1;
            More = spans.Next();
        }
Пример #4
0
            public override Explanation Explain(AtomicReaderContext context, int doc)
            {
                PayloadTermSpanScorer scorer = (PayloadTermSpanScorer)Scorer(context, (context.AtomicReader).LiveDocs);

                if (scorer != null)
                {
                    int newDoc = scorer.Advance(doc);
                    if (newDoc == doc)
                    {
                        float freq = scorer.SloppyFreq();
                        Similarity.SimScorer docScorer = Similarity.DoSimScorer(Stats, context);
                        Explanation          expl      = new Explanation();
                        expl.Description = "weight(" + Query + " in " + doc + ") [" + Similarity.GetType().Name + "], result of:";
                        Explanation scoreExplanation = docScorer.Explain(doc, new Explanation(freq, "phraseFreq=" + freq));
                        expl.AddDetail(scoreExplanation);
                        expl.Value = scoreExplanation.Value;
                        // now the payloads part
                        // QUESTION: Is there a way to avoid this skipTo call? We need to know
                        // whether to load the payload or not
                        // GSI: I suppose we could toString the payload, but I don't think that
                        // would be a good idea
                        string      field       = ((SpanQuery)Query).Field;
                        Explanation payloadExpl = OuterInstance.Function.Explain(doc, field, scorer.PayloadsSeen, scorer.PayloadScore_Renamed);
                        payloadExpl.Value = scorer.PayloadScore;
                        // combined
                        ComplexExplanation result = new ComplexExplanation();
                        if (OuterInstance.IncludeSpanScore)
                        {
                            result.AddDetail(expl);
                            result.AddDetail(payloadExpl);
                            result.Value       = expl.Value * payloadExpl.Value;
                            result.Description = "btq, product of:";
                        }
                        else
                        {
                            result.AddDetail(payloadExpl);
                            result.Value       = payloadExpl.Value;
                            result.Description = "btq(includeSpanScore=false), result of:";
                        }
                        result.Match = true; // LUCENE-1303
                        return(result);
                    }
                }

                return(new ComplexExplanation(false, 0.0f, "no matching term"));
            }
Пример #5
0
 /// <summary>
 /// Construct a <code>TermScorer</code>.
 /// </summary>
 /// <param name="weight">
 ///          The weight of the <code>Term</code> in the query. </param>
 /// <param name="td">
 ///          An iterator over the documents matching the <code>Term</code>. </param>
 /// <param name="docScorer">
 ///          The </code>Similarity.SimScorer</code> implementation
 ///          to be used for score computations. </param>
 internal TermScorer(Weight weight, DocsEnum td, Similarity.SimScorer docScorer)
     : base(weight)
 {
     this.DocScorer = docScorer;
     this.DocsEnum = td;
 }
Пример #6
0
 public PayloadTermSpanScorer(PayloadTermQuery.PayloadTermWeight outerInstance, TermSpans spans, Weight weight, Similarity.SimScorer docScorer)
     : base(spans, weight, docScorer)
 {
     this.OuterInstance = outerInstance;
     TermSpans          = spans;
 }