コード例 #1
0
        /// <summary>
        /// Creates a <see cref="TermContext"/> from a top-level <see cref="IndexReaderContext"/> and the
        /// given <see cref="Term"/>. this method will lookup the given term in all context's leaf readers
        /// and register each of the readers containing the term in the returned <see cref="TermContext"/>
        /// using the leaf reader's ordinal.
        /// <para/>
        /// Note: the given context must be a top-level context.
        /// </summary>
        public static TermContext Build(IndexReaderContext context, Term term)
        {
            if (Debugging.AssertsEnabled)
            {
                Debugging.Assert(context != null && context.IsTopLevel);
            }
            string      field = term.Field;
            BytesRef    bytes = term.Bytes;
            TermContext perReaderTermState = new TermContext(context);

            //if (DEBUG) System.out.println("prts.build term=" + term);
            foreach (AtomicReaderContext ctx in context.Leaves)
            {
                //if (DEBUG) System.out.println("  r=" + leaves[i].reader);
                Fields fields = ctx.AtomicReader.Fields;
                if (fields != null)
                {
                    Terms terms = fields.GetTerms(field);
                    if (terms != null)
                    {
                        TermsEnum termsEnum = terms.GetEnumerator();
                        if (termsEnum.SeekExact(bytes))
                        {
                            TermState termState = termsEnum.GetTermState();
                            //if (DEBUG) System.out.println("    found");
                            perReaderTermState.Register(termState, ctx.Ord, termsEnum.DocFreq, termsEnum.TotalTermFreq);
                        }
                    }
                }
            }
            return(perReaderTermState);
        }
コード例 #2
0
 /// <summary>
 /// Returns the filtered enums term state
 /// </summary>
 public override TermState GetTermState()
 {
     if (Debugging.AssertsEnabled)
     {
         Debugging.Assert(tenum != null);
     }
     return(tenum.GetTermState());
 }
コード例 #3
0
 /// <summary>
 /// Returns the filtered enums term state
 /// </summary>
 public override TermState GetTermState()
 {
     Debug.Assert(tenum != null);
     return(tenum.GetTermState());
 }