Exemple #1
0
 public virtual void SetNextReader(AtomicReaderContext context)
 {
     foreach (ICollector c in collectors)
     {
         c.SetNextReader(context);
     }
 }
 public DocIdSetAnonymousInnerClassHelper(QueryWrapperFilter outerInstance, IBits acceptDocs, AtomicReaderContext privateContext, Lucene.Net.Search.Weight weight)
 {
     this.outerInstance  = outerInstance;
     this.acceptDocs     = acceptDocs;
     this.privateContext = privateContext;
     this.weight         = weight;
 }
        public override DocIdSet GetDocIdSet(AtomicReaderContext context, IBits acceptDocs)
        {
            SortedDocValues fcsi = FieldCache.GetTermsIndex((context.AtomicReader), field);
            FixedBitSet     bits = new FixedBitSet(fcsi.ValueCount);

            for (int i = 0; i < terms.Length; i++)
            {
                int ord = fcsi.LookupTerm(terms[i]);
                if (ord >= 0)
                {
                    bits.Set(ord);
                }
            }
            return(new FieldCacheDocIdSet(context.Reader.MaxDoc, acceptDocs, (doc) =>
            {
                int ord = fcsi.GetOrd(doc);
                if (ord == -1)
                {
                    // missing
                    return false;
                }
                else
                {
                    return bits.Get(ord);
                }
            }));
        }
        public override DocIdSet GetDocIdSet(AtomicReaderContext context, IBits acceptDocs)
        {
            // get a private context that is used to rewrite, createWeight and score eventually
            AtomicReaderContext privateContext = context.AtomicReader.AtomicContext;
            Weight weight = (new IndexSearcher(privateContext)).CreateNormalizedWeight(query);

            return(new DocIdSetAnonymousInnerClassHelper(this, acceptDocs, privateContext, weight));
        }
Exemple #5
0
 public override SimScorer GetSimScorer(SimWeight stats, AtomicReaderContext context)
 {
     SimScorer[] subScorers = new SimScorer[m_sims.Length];
     for (int i = 0; i < subScorers.Length; i++)
     {
         subScorers[i] = m_sims[i].GetSimScorer(((MultiStats)stats).subStats[i], context);
     }
     return(new MultiSimScorer(subScorers));
 }
Exemple #6
0
        /// <summary>
        /// Optional method, to return a <see cref="BulkScorer"/> to
        /// score the query and send hits to a <see cref="ICollector"/>.
        /// Only queries that have a different top-level approach
        /// need to override this; the default implementation
        /// pulls a normal <see cref="Scorer"/> and iterates and
        /// collects the resulting hits.
        /// </summary>
        /// <param name="context">
        ///          The <see cref="AtomicReaderContext"/> for which to return the <see cref="Scorer"/>. </param>
        /// <param name="scoreDocsInOrder">
        ///          Specifies whether in-order scoring of documents is required. Note
        ///          that if set to <c>false</c> (i.e., out-of-order scoring is required),
        ///          this method can return whatever scoring mode it supports, as every
        ///          in-order scorer is also an out-of-order one. However, an
        ///          out-of-order scorer may not support <see cref="DocIdSetIterator.NextDoc()"/>
        ///          and/or <see cref="DocIdSetIterator.Advance(int)"/>, therefore it is recommended to
        ///          request an in-order scorer if use of these
        ///          methods is required. </param>
        /// <param name="acceptDocs">
        ///          <see cref="IBits"/> that represent the allowable docs to match (typically deleted docs
        ///          but possibly filtering other documents)
        /// </param>
        /// <returns> A <see cref="BulkScorer"/> which scores documents and
        /// passes them to a collector. </returns>
        /// <exception cref="System.IO.IOException"> if there is a low-level I/O error </exception>
        public virtual BulkScorer GetBulkScorer(AtomicReaderContext context, bool scoreDocsInOrder, IBits acceptDocs)
        {
            Scorer scorer = GetScorer(context, acceptDocs);

            if (scorer == null)
            {
                // No docs match
                return(null);
            }

            // this impl always scores docs in order, so we can
            // ignore scoreDocsInOrder:
            return(new DefaultBulkScorer(scorer));
        }
        public override DocIdSet GetDocIdSet(AtomicReaderContext context, IBits acceptDocs)
        {
            SortedDocValues fcsi = FieldCache.GetTermsIndex((context.AtomicReader), field);
            FixedBitSet     bits = new FixedBitSet(fcsi.ValueCount);

            for (int i = 0; i < terms.Length; i++)
            {
                int ord = fcsi.LookupTerm(terms[i]);
                if (ord >= 0)
                {
                    bits.Set(ord);
                }
            }
            return(new FieldCacheDocIdSetAnonymousInnerClassHelper(this, context.Reader.MaxDoc, acceptDocs, fcsi, bits));
        }
Exemple #8
0
            public override Explanation Explain(AtomicReaderContext context, int doc)
            {
                PayloadTermSpanScorer scorer = (PayloadTermSpanScorer)GetScorer(context, (context.AtomicReader).LiveDocs);

                if (scorer != null)
                {
                    int newDoc = scorer.Advance(doc);
                    if (newDoc == doc)
                    {
                        float freq = scorer.SloppyFreq;
                        Similarity.SimScorer docScorer = m_similarity.GetSimScorer(m_stats, context);
                        Explanation          expl      = new Explanation();
                        expl.Description = "weight(" + Query + " in " + doc + ") [" + m_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.m_function.Explain(doc, field, scorer.m_payloadsSeen, scorer.m_payloadScore);
                        payloadExpl.Value = scorer.GetPayloadScore();
                        // 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"));
            }
Exemple #9
0
 public override SimScorer GetSimScorer(SimWeight stats, AtomicReaderContext context)
 {
     if (stats is MultiSimilarity.MultiStats)
     {
         // a multi term query (e.g. phrase). return the summation,
         // scoring almost as if it were boolean query
         SimWeight[] subStats   = ((MultiSimilarity.MultiStats)stats).subStats;
         SimScorer[] subScorers = new SimScorer[subStats.Length];
         for (int i = 0; i < subScorers.Length; i++)
         {
             BasicStats basicstats = (BasicStats)subStats[i];
             subScorers[i] = new BasicSimScorer(this, basicstats, context.AtomicReader.GetNormValues(basicstats.Field));
         }
         return(new MultiSimilarity.MultiSimScorer(subScorers));
     }
     else
     {
         BasicStats basicstats = (BasicStats)stats;
         return(new BasicSimScorer(this, basicstats, context.AtomicReader.GetNormValues(basicstats.Field)));
     }
 }
 public virtual void SetNextReader(AtomicReaderContext context)
 {
     c.SetNextReader(context);
 }
Exemple #11
0
 public override Scorer GetScorer(AtomicReaderContext context, IBits acceptDocs)
 {
     return(new PayloadTermSpanScorer(this, (TermSpans)m_query.GetSpans(context, acceptDocs, m_termContexts), this, m_similarity.GetSimScorer(m_stats, context)));
 }
 public override sealed SimScorer GetSimScorer(SimWeight weight, AtomicReaderContext context)
 {
     PerFieldSimWeight perFieldWeight = (PerFieldSimWeight)weight;
     return [email protected](perFieldWeight.delegateWeight, context);
 }
Exemple #13
0
 /// <summary>
 /// Creates a new <see cref="Similarity.SimScorer"/> to score matching documents from a segment of the inverted index. </summary>
 /// <param name="weight"> collection information from <see cref="ComputeWeight(float, CollectionStatistics, TermStatistics[])"/> </param>
 /// <param name="context"> segment of the inverted index to be scored. </param>
 /// <returns> Sloppy <see cref="SimScorer"/> for scoring documents across <c>context</c> </returns>
 /// <exception cref="System.IO.IOException"> if there is a low-level I/O error </exception>
 public abstract SimScorer GetSimScorer(SimWeight weight, AtomicReaderContext context);
Exemple #14
0
 /// <summary>
 /// An explanation of the score computation for the named document.
 /// </summary>
 /// <param name="context"> The readers context to create the <see cref="Explanation"/> for. </param>
 /// <param name="doc"> The document's id relative to the given context's reader </param>
 /// <returns> An <see cref="Explanation"/> for the score </returns>
 /// <exception cref="System.IO.IOException"> if an <see cref="System.IO.IOException"/> occurs </exception>
 public abstract Explanation Explain(AtomicReaderContext context, int doc);
Exemple #15
0
 /// <summary>
 /// Returns a <see cref="Scorer"/> which scores documents in/out-of order according
 /// to <c>scoreDocsInOrder</c>.
 /// <para/>
 /// <b>NOTE:</b> even if <c>scoreDocsInOrder</c> is <c>false</c>, it is
 /// recommended to check whether the returned <see cref="Scorer"/> indeed scores
 /// documents out of order (i.e., call <see cref="ScoresDocsOutOfOrder"/>), as
 /// some <see cref="Scorer"/> implementations will always return documents
 /// in-order.
 /// <para/>
 /// <b>NOTE:</b> <c>null</c> can be returned if no documents will be scored by this
 /// query.
 /// </summary>
 /// <param name="context">
 ///          The <see cref="AtomicReaderContext"/> for which to return the <see cref="Scorer"/>. </param>
 /// <param name="acceptDocs">
 ///          <see cref="IBits"/> that represent the allowable docs to match (typically deleted docs
 ///          but possibly filtering other documents)
 /// </param>
 /// <returns> A <see cref="Scorer"/> which scores documents in/out-of order. </returns>
 /// <exception cref="System.IO.IOException"> if there is a low-level I/O error </exception>
 public abstract Scorer GetScorer(AtomicReaderContext context, IBits acceptDocs);