Ejemplo n.º 1
0
        private int CountTerms(MultiTermQuery q)
        {
            Terms terms = MultiFields.GetTerms(Reader, q.Field);

            if (terms == null)
            {
                return(0);
            }
            TermsEnum termEnum = q.GetTermsEnum(terms);

            Assert.IsNotNull(termEnum);
            int      count = 0;
            BytesRef cur, last = null;

            while ((cur = termEnum.Next()) != null)
            {
                count++;
                if (last != null)
                {
                    Assert.IsTrue(last.CompareTo(cur) < 0);
                }
                last = BytesRef.DeepCopyOf(cur);
            }
            // LUCENE-3314: the results after next() already returned null are undefined,
            // Assert.IsNull(termEnum.Next());
            return(count);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Returns the <see cref="MultiTermQuery"/>s <see cref="TermsEnum"/> </summary>
 /// <seealso cref="MultiTermQuery.GetTermsEnum(Terms, AttributeSource)"/>
 protected virtual TermsEnum GetTermsEnum(MultiTermQuery query, Terms terms, AttributeSource atts)
 {
     return(query.GetTermsEnum(terms, atts)); // allow RewriteMethod subclasses to pull a TermsEnum from the MTQ
 }
 private int CountTerms(MultiTermQuery q)
 {
     Terms terms = MultiFields.GetTerms(Reader, q.Field);
     if (terms == null)
     {
         return 0;
     }
     TermsEnum termEnum = q.GetTermsEnum(terms);
     Assert.IsNotNull(termEnum);
     int count = 0;
     BytesRef cur, last = null;
     while ((cur = termEnum.Next()) != null)
     {
         count++;
         if (last != null)
         {
             Assert.IsTrue(last.CompareTo(cur) < 0);
         }
         last = BytesRef.DeepCopyOf(cur);
     }
     // LUCENE-3314: the results after next() already returned null are undefined,
     // Assert.IsNull(termEnum.Next());
     return count;
 }