/// <summary>
        /// Enumerates all terms greater/equal than <code>lowerTerm</code>
        /// but less/equal than <code>upperTerm</code>.
        ///
        /// If an endpoint is null, it is said to be "open". Either or both
        /// endpoints may be open.  Open endpoints may not be exclusive
        /// (you can't select all but the first or last term without
        /// explicitly specifying the term to exclude.)
        /// </summary>
        /// <param name="tenum">
        ///          TermsEnum to filter </param>
        /// <param name="lowerTerm">
        ///          The term text at the lower end of the range </param>
        /// <param name="upperTerm">
        ///          The term text at the upper end of the range </param>
        /// <param name="includeLower">
        ///          If true, the <code>lowerTerm</code> is included in the range. </param>
        /// <param name="includeUpper">
        ///          If true, the <code>upperTerm</code> is included in the range. </param>
        public TermRangeTermsEnum(TermsEnum tenum, BytesRef lowerTerm, BytesRef upperTerm, bool includeLower, bool includeUpper)
            : base(tenum)
        {
            // do a little bit of normalization...
            // open ended range queries should always be inclusive.
            if (lowerTerm == null)
            {
                this.LowerBytesRef = new BytesRef();
                this.IncludeLower = true;
            }
            else
            {
                this.LowerBytesRef = lowerTerm;
                this.IncludeLower = includeLower;
            }

            if (upperTerm == null)
            {
                this.IncludeUpper = true;
                UpperBytesRef = null;
            }
            else
            {
                this.IncludeUpper = includeUpper;
                UpperBytesRef = upperTerm;
            }

            InitialSeekTerm = LowerBytesRef;
            TermComp = Comparator;
        }
Example #2
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();
        }
Example #3
0
 public PrefixTermsEnum(TermsEnum tenum, BytesRef prefixText)
     : base(tenum)
 {
     InitialSeekTerm = this.PrefixRef = prefixText;
 }
 internal SimplePrefixTermsEnum(TestPrefixRandom.DumbPrefixQuery outerInstance, TermsEnum tenum, BytesRef prefix)
     : base(tenum)
 {
     this.OuterInstance = outerInstance;
     this.Prefix = prefix;
     InitialSeekTerm = new BytesRef("");
 }
Example #5
0
 public AutomatonTermsEnumAnonymousInnerClassHelper(Terms outerInstance, Lucene.Net.Index.TermsEnum iterator, CompiledAutomaton compiled, BytesRef startTerm)
     : base(iterator, compiled)
 {
     this.outerInstance = outerInstance;
     this.startTerm     = startTerm;
 }
Example #6
0
                internal SimpleAutomatonTermsEnum(TestRegexpRandom2.DumbRegexpQuery outerInstance, TermsEnum tenum)
                    : base(tenum)
                {
                    this.OuterInstance = outerInstance;

                    if (!InstanceFieldsInitialized)
                    {
                        InitializeInstanceFields();
                        InstanceFieldsInitialized = true;
                    }
                    InitialSeekTerm = new BytesRef("");
                }
 public CompressedBinaryDocValues(BinaryEntry bytes, MonotonicBlockPackedReader addresses, IndexInput data)
 {
     this.Bytes = bytes;
     this.Interval = bytes.AddressInterval;
     this.Addresses = addresses;
     this.Data = data;
     this.NumValues = bytes.Count;
     this.NumIndexValues = addresses.Size();
     this.TermsEnum_Renamed = GetTermsEnum(data);
 }
Example #8
0
 public FilteredTermsEnumAnonymousInnerClassHelper2(TermsEnum termsEnum)
     : base(termsEnum, false)
 {
 }
Example #9
0
 /// <summary>
 /// Filters the given <seealso cref="TermsEnum"/> by accepting only prefix coded 64 bit
 /// terms with a shift value of <tt>0</tt>.
 /// </summary>
 /// <param name="termsEnum">
 ///          the terms enum to filter </param>
 /// <returns> a filtered <seealso cref="TermsEnum"/> that only returns prefix coded 64 bit
 ///         terms with a shift value of <tt>0</tt>. </returns>
 public static TermsEnum FilterPrefixCodedLongs(TermsEnum termsEnum)
 {
     return new FilteredTermsEnumAnonymousInnerClassHelper(termsEnum);
 }
Example #10
0
 public PrefixTermsEnum(TermsEnum tenum, BytesRef prefixText)
     : base(tenum)
 {
     InitialSeekTerm = this.PrefixRef = prefixText;
 }
Example #11
0
 public PrefixTermsEnum(TermsEnum tenum, BytesRef prefixText)
     : base(tenum)
 {
     SetInitialSeekTerm(this.prefixRef = prefixText);
 }
Example #12
0
                internal SimpleAutomatonTermsEnum(TestRegexpRandom2.DumbRegexpQuery outerInstance, TermsEnum tenum)
                    : base(tenum)
                {
                    this.outerInstance = outerInstance;

                    runAutomaton = new CharacterRunAutomaton(outerInstance.automaton);
                    SetInitialSeekTerm(new BytesRef(""));
                }
 private void VerifyVector(TermsEnum vector, int num)
 {
     StringBuilder temp = new StringBuilder();
     while (vector.Next() != null)
     {
         temp.Append(vector.Term().Utf8ToString());
     }
     if (!English.IntToEnglish(num).Trim().Equals(temp.ToString().Trim()))
     {
         Console.WriteLine("wrong term result");
     }
 }
 public TermRangeTermsEnumAnonymousInnerClassHelper(MultiTermQueryAnonymousInnerClassHelper outerInstance, TermsEnum iterator, BytesRef bref1, BytesRef bref2)
     : base(iterator, bref1, bref2, true, true)
 {
     this.OuterInstance = outerInstance;
     boostAtt = Attributes().AddAttribute<IBoostAttribute>();
 }