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); }
public override TermsEnum GetTermsEnum(Terms terms, AttributeSource atts) { return new SimpleAutomatonTermsEnum(this, terms.Iterator(null)); }
public TermsEnum TermsEnum(Terms terms) { return terms.Iterator(null); }
/// <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 }
/// <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())); }
/// <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);
public TermsEnum TermsEnum(Terms terms) { return NumericUtils.FilterPrefixCodedLongs(terms.Iterator(null)); }
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")); }
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); }
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); }