Пример #1
0
        /// <summary>Advance to non excluded doc.
        /// <br/>On entry:
        /// <ul>
        /// <li>reqScorer != null, </li>
        /// <li>exclScorer != null, </li>
        /// <li>reqScorer was advanced once via next() or skipTo()
        /// and reqScorer.doc() may still be excluded.</li>
        /// </ul>
        /// Advances reqScorer a non excluded required doc, if any.
        /// </summary>
        /// <returns> true iff there is a non excluded required doc.
        /// </returns>
        private int ToNonExcluded()
        {
            int exclDoc = exclDisi.DocID();
            int reqDoc  = reqScorer.DocID();            // may be excluded

            do
            {
                if (reqDoc < exclDoc)
                {
                    return(reqDoc);                    // reqScorer advanced to before exclScorer, ie. not excluded
                }
                else if (reqDoc > exclDoc)
                {
                    exclDoc = exclDisi.Advance(reqDoc);
                    if (exclDoc == NO_MORE_DOCS)
                    {
                        exclDisi = null;                         // exhausted, no more exclusions
                        return(reqDoc);
                    }
                    if (exclDoc > reqDoc)
                    {
                        return(reqDoc);                        // not excluded
                    }
                }
            }while ((reqDoc = reqScorer.NextDoc()) != NO_MORE_DOCS);
            reqScorer = null;             // exhausted, nothing left
            return(NO_MORE_DOCS);
        }
Пример #2
0
            public override Explanation Explain(IndexReader ir, int i)
            {
                Explanation inner = weight.Explain(ir, i);

                if (Enclosing_Instance.GetBoost() != 1)
                {
                    Explanation preBoost = inner;
                    inner = new Explanation(inner.GetValue() * Enclosing_Instance.GetBoost(), "product of:");
                    inner.AddDetail(new Explanation(Enclosing_Instance.GetBoost(), "boost"));
                    inner.AddDetail(preBoost);
                }
                Filter           f                = Enclosing_Instance.filter;
                DocIdSet         docIdSet         = f.GetDocIdSet(ir);
                DocIdSetIterator docIdSetIterator = docIdSet == null?DocIdSet.EMPTY_DOCIDSET.Iterator() : docIdSet.Iterator();

                if (docIdSetIterator == null)
                {
                    docIdSetIterator = DocIdSet.EMPTY_DOCIDSET.Iterator();
                }
                if (docIdSetIterator.Advance(i) == i)
                {
                    return(inner);
                }
                else
                {
                    Explanation result = new Explanation(0.0f, "failure to match filter: " + f.ToString());
                    result.AddDetail(inner);
                    return(result);
                }
            }
Пример #3
0
        private void  SearchWithFilter(IndexReader reader, Weight weight, Filter filter, Collector collector)
        {
            System.Diagnostics.Debug.Assert(filter != null);

            Scorer scorer = weight.Scorer(reader, true, false);

            if (scorer == null)
            {
                return;
            }

            int docID = scorer.DocID();

            System.Diagnostics.Debug.Assert(docID == -1 || docID == DocIdSetIterator.NO_MORE_DOCS);

            // CHECKME: use ConjunctionScorer here?
            DocIdSet filterDocIdSet = filter.GetDocIdSet(reader);

            if (filterDocIdSet == null)
            {
                // this means the filter does not accept any documents.
                return;
            }

            DocIdSetIterator filterIter = filterDocIdSet.Iterator();

            if (filterIter == null)
            {
                // this means the filter does not accept any documents.
                return;
            }
            int filterDoc = filterIter.NextDoc();
            int scorerDoc = scorer.Advance(filterDoc);

            collector.SetScorer(scorer);
            while (true)
            {
                if (scorerDoc == filterDoc)
                {
                    // Check if scorer has exhausted, only before collecting.
                    if (scorerDoc == DocIdSetIterator.NO_MORE_DOCS)
                    {
                        break;
                    }
                    collector.Collect(scorerDoc);
                    filterDoc = filterIter.NextDoc();
                    scorerDoc = scorer.Advance(filterDoc);
                }
                else if (scorerDoc > filterDoc)
                {
                    filterDoc = filterIter.Advance(scorerDoc);
                }
                else
                {
                    scorerDoc = scorer.Advance(filterDoc);
                }
            }
        }
Пример #4
0
 public override int Advance(int target)
 {
     doc = _innerIter.Advance(target);
     if (doc != NO_MORE_DOCS)
     {
         if (Match(doc))
         {
             return(doc);
         }
         else
         {
             while ((doc = _innerIter.NextDoc()) != NO_MORE_DOCS)
             {
                 if (Match(doc))
                 {
                     return(doc);
                 }
             }
             return(doc);
         }
     }
     return(doc);
 }
Пример #5
0
 public override bool SkipTo(int target)
 {
     return(docIdSetIterator.Advance(target) != NO_MORE_DOCS);
 }