Esempio n. 1
0
        public virtual void TestNoOrds()
        {
            Directory dir = NewDirectory();
            RandomIndexWriter iw = new RandomIndexWriter(Random, dir);
            Document doc = new Document();
            FieldType ft = new FieldType(TextField.TYPE_NOT_STORED);
            ft.StoreTermVectors = true;
            doc.Add(new Field("foo", "this is a test", ft));
            iw.AddDocument(doc);
            AtomicReader ir = GetOnlySegmentReader(iw.GetReader());
            Terms terms = ir.GetTermVector(0, "foo");
            Assert.IsNotNull(terms);
            TermsEnum termsEnum = terms.GetEnumerator();
            Assert.AreEqual(TermsEnum.SeekStatus.FOUND, termsEnum.SeekCeil(new BytesRef("this")));
            try
            {
                var _ = termsEnum.Ord;
                Assert.Fail();
            }
            catch (Exception expected) when (expected.IsUnsupportedOperationException())
            {
                // expected exception
            }

            try
            {
                termsEnum.SeekExact(0);
                Assert.Fail();
            }
            catch (Exception expected) when (expected.IsUnsupportedOperationException())
            {
                // expected exception
            }
            ir.Dispose();
            iw.Dispose();
            dir.Dispose();
        }
 public override TermsEnum GetTermsEnum(Terms terms, AttributeSource atts)
 {
     return new SimplePrefixTermsEnum(this, terms.Iterator(null), Prefix);
 }
Esempio n. 3
0
 public override TermsEnum GetTermsEnum(Terms terms, AttributeSource atts)
 {
     return new SimpleAutomatonTermsEnum(this, terms.Iterator(null));
 }
Esempio n. 4
0
 public TermsEnum TermsEnum(Terms terms)
 {
     return terms.Iterator(null);
 }
Esempio n. 5
0
 /// <summary>
 /// Returns the <seealso cref="MultiTermQuery"/>s <seealso cref="TermsEnum"/> </summary>
 /// <seealso cref= MultiTermQuery#getTermsEnum(Terms, AttributeSource) </seealso>
 protected internal virtual TermsEnum GetTermsEnum(MultiTermQuery query, Terms terms, AttributeSource atts)
 {
     return(query.GetTermsEnum(terms, atts)); // allow RewriteMethod subclasses to pull a TermsEnum from the MTQ
 }
Esempio n. 6
0
 /// <summary>
 /// Convenience method, if no attributes are needed:
 /// this simply passes empty attributes and is equal to:
 /// <code>getTermsEnum(terms, new AttributeSource())</code>
 /// </summary>
 public TermsEnum GetTermsEnum(Terms terms)
 {
     return(GetTermsEnum(terms, new AttributeSource()));
 }
Esempio n. 7
0
 /// <summary>
 /// Construct the enumeration to be used, expanding the
 ///  pattern term.  this method should only be called if
 ///  the field exists (ie, implementations can assume the
 ///  field does exist).  this method should not return null
 ///  (should instead return <seealso cref="TermsEnum#EMPTY"/> if no
 ///  terms match).  The TermsEnum must already be
 ///  positioned to the first matching term.
 /// The given <seealso cref="AttributeSource"/> is passed by the <seealso cref="RewriteMethod"/> to
 /// provide attributes, the rewrite method uses to inform about e.g. maximum competitive boosts.
 /// this is currently only used by <seealso cref="TopTermsRewrite"/>
 /// </summary>
 public abstract TermsEnum GetTermsEnum(Terms terms, AttributeSource atts);
Esempio n. 8
0
 public TermsEnum TermsEnum(Terms terms)
 {
     return NumericUtils.FilterPrefixCodedLongs(terms.Iterator(null));
 }
Esempio n. 9
0
 protected override TermsEnum GetTermsEnum(Terms terms, AttributeSource atts)
 {
     return new SimpleAutomatonTermsEnum(this, terms.GetEnumerator());
 }
 public override TermsEnum GetTermsEnum(Terms terms, AttributeSource atts)
 {
     return new TermRangeTermsEnumAnonymousInnerClassHelper(this, terms.Iterator(null), new BytesRef("2"), new BytesRef("7"));
 }
Esempio n. 11
0
 public override TermsEnum GetTermsEnum(Terms terms, AttributeSource atts)
 {
     if (MaxEdits_Renamed == 0 || PrefixLength_Renamed >= _term.Text().Length) // can only match if it's exact
     {
         return new SingleTermsEnum(terms.Iterator(null), _term.Bytes);
     }
     return new FuzzyTermsEnum(terms, atts, Term, MaxEdits_Renamed, PrefixLength_Renamed, Transpositions_Renamed);
 }
Esempio n. 12
0
        public override TermsEnum GetTermsEnum(Terms terms, AttributeSource atts)
        {
            TermsEnum tenum = terms.Iterator(null);

            if (_prefix.Bytes.Length == 0)
            {
                // no prefix -- match all terms for this field:
                return tenum;
            }
            return new PrefixTermsEnum(tenum, _prefix.Bytes);
        }