當前位置: 首頁>>代碼示例>>C#>>正文


C# IndexReader.Terms方法代碼示例

本文整理匯總了C#中Transformalize.Libs.Lucene.Net.Index.IndexReader.Terms方法的典型用法代碼示例。如果您正苦於以下問題:C# IndexReader.Terms方法的具體用法?C# IndexReader.Terms怎麽用?C# IndexReader.Terms使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Transformalize.Libs.Lucene.Net.Index.IndexReader的用法示例。


在下文中一共展示了IndexReader.Terms方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: WildcardTermEnum

        /// <summary> Creates a new <c>WildcardTermEnum</c>.
        /// <p/>
        /// After calling the constructor the enumeration is already pointing to the first 
        /// valid term if such a term exists.
        /// </summary>
        public WildcardTermEnum(IndexReader reader, Term term):base()
        {
            searchTerm = term;
            field = searchTerm.Field;
            System.String searchTermText = searchTerm.Text;
            
            int sidx = searchTermText.IndexOf((System.Char) WILDCARD_STRING);
            int cidx = searchTermText.IndexOf((System.Char) WILDCARD_CHAR);
            int idx = sidx;
            if (idx == - 1)
            {
                idx = cidx;
            }
            else if (cidx >= 0)
            {
                idx = System.Math.Min(idx, cidx);
            }
            pre = idx != - 1?searchTerm.Text.Substring(0, (idx) - (0)):"";
            
            preLen = pre.Length;
            text = searchTermText.Substring(preLen);
            SetEnum(reader.Terms(new Term(searchTerm.Field, pre)));
        }
開發者ID:mindis,項目名稱:Transformalize,代碼行數:28,代碼來源:WildcardTermEnum.cs

示例2: CreateValue

 protected internal override System.Object CreateValue(IndexReader reader, Entry entryKey)
 {
     System.String field = StringHelper.Intern(entryKey.field);
     int[] retArray = new int[reader.MaxDoc];
     System.String[] mterms = new System.String[reader.MaxDoc + 1];
     TermDocs termDocs = reader.TermDocs();
     TermEnum termEnum = reader.Terms(new Term(field));
     int t = 0; // current term number
     
     // an entry for documents that have no terms in this field
     // should a document with no terms be at top or bottom?
     // this puts them at the top - if it is changed, FieldDocSortedHitQueue
     // needs to change as well.
     mterms[t++] = null;
     
     try
     {
         do 
         {
             Term term = termEnum.Term;
             if (term == null || term.Field != field || t >= mterms.Length) break;
             
             // store term text
             mterms[t] = term.Text;
             
             termDocs.Seek(termEnum);
             while (termDocs.Next())
             {
                 retArray[termDocs.Doc] = t;
             }
             
             t++;
         }
         while (termEnum.Next());
     }
     finally
     {
         termDocs.Close();
         termEnum.Close();
     }
     
     if (t == 0)
     {
         // if there are no terms, make the term array
         // have a single null entry
         mterms = new System.String[1];
     }
     else if (t < mterms.Length)
     {
         // if there are less terms than documents,
         // trim off the dead array space
         System.String[] terms = new System.String[t];
         Array.Copy(mterms, 0, terms, 0, t);
         mterms = terms;
     }
     
     StringIndex value_Renamed = new StringIndex(retArray, mterms);
     return value_Renamed;
 }
開發者ID:mindis,項目名稱:Transformalize,代碼行數:59,代碼來源:FieldCacheImpl.cs

示例3: TermRangeTermEnum

        /// <summary> Enumerates all terms greater/equal than <c>lowerTerm</c>
        /// but less/equal than <c>upperTerm</c>. 
        /// 
        /// 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="reader">
        /// </param>
        /// <param name="field">An interned field that holds both lower and upper terms.
        /// </param>
        /// <param name="lowerTermText">The term text at the lower end of the range
        /// </param>
        /// <param name="upperTermText">The term text at the upper end of the range
        /// </param>
        /// <param name="includeLower">If true, the <c>lowerTerm</c> is included in the range.
        /// </param>
        /// <param name="includeUpper">If true, the <c>upperTerm</c> is included in the range.
        /// </param>
        /// <param name="collator">The collator to use to collate index Terms, to determine their
        /// membership in the range bounded by <c>lowerTerm</c> and
        /// <c>upperTerm</c>.
        /// 
        /// </param>
        /// <throws>  IOException </throws>
        public TermRangeTermEnum(IndexReader reader, System.String field, System.String lowerTermText, System.String upperTermText, bool includeLower, bool includeUpper, System.Globalization.CompareInfo collator)
        {
            this.collator = collator;
            this.upperTermText = upperTermText;
            this.lowerTermText = lowerTermText;
            this.includeLower = includeLower;
            this.includeUpper = includeUpper;
            this.field = StringHelper.Intern(field);
            
            // do a little bit of normalization...
            // open ended range queries should always be inclusive.
            if (this.lowerTermText == null)
            {
                this.lowerTermText = "";
                this.includeLower = true;
            }
            
            if (this.upperTermText == null)
            {
                this.includeUpper = true;
            }
            
            System.String startTermText = collator == null?this.lowerTermText:"";
            SetEnum(reader.Terms(new Term(this.field, startTermText)));
        }
開發者ID:mindis,項目名稱:Transformalize,代碼行數:52,代碼來源:TermRangeTermEnum.cs

示例4: PrefixTermEnum

        public PrefixTermEnum(IndexReader reader, Term prefix)
        {
            this.prefix = prefix;
            
            SetEnum(reader.Terms(new Term(prefix.Field, prefix.Text)));
        }
開發者ID:mindis,項目名稱:Transformalize,代碼行數:6,代碼來源:PrefixTermEnum.cs

示例5: FuzzyTermEnum

        /// <summary> Constructor for enumeration of all terms from specified <c>reader</c> which share a prefix of
        /// length <c>prefixLength</c> with <c>term</c> and which have a fuzzy similarity &gt;
        /// <c>minSimilarity</c>.
        /// <p/>
        /// After calling the constructor the enumeration is already pointing to the first 
        /// valid term if such a term exists. 
        /// 
        /// </summary>
        /// <param name="reader">Delivers terms.
        /// </param>
        /// <param name="term">Pattern term.
        /// </param>
        /// <param name="minSimilarity">Minimum required similarity for terms from the reader. Default value is 0.5f.
        /// </param>
        /// <param name="prefixLength">Length of required common prefix. Default value is 0.
        /// </param>
        /// <throws>  IOException </throws>
        public FuzzyTermEnum(IndexReader reader, Term term, float minSimilarity, int prefixLength):base()
        {
            
            if (minSimilarity >= 1.0f)
                throw new System.ArgumentException("minimumSimilarity cannot be greater than or equal to 1");
            else if (minSimilarity < 0.0f)
                throw new System.ArgumentException("minimumSimilarity cannot be less than 0");
            if (prefixLength < 0)
                throw new System.ArgumentException("prefixLength cannot be less than 0");
            
            this.minimumSimilarity = minSimilarity;
            this.scale_factor = 1.0f / (1.0f - minimumSimilarity);
            this.searchTerm = term;
            this.field = searchTerm.Field;
            
            //The prefix could be longer than the word.
            //It's kind of silly though.  It means we must match the entire word.
            int fullSearchTermLength = searchTerm.Text.Length;
            int realPrefixLength = prefixLength > fullSearchTermLength?fullSearchTermLength:prefixLength;
            
            this.text = searchTerm.Text.Substring(realPrefixLength);
            this.prefix = searchTerm.Text.Substring(0, (realPrefixLength) - (0));

            this.p = new int[this.text.Length + 1];
            this.d = new int[this.text.Length + 1];
            
            SetEnum(reader.Terms(new Term(searchTerm.Field, prefix)));
        }
開發者ID:mindis,項目名稱:Transformalize,代碼行數:45,代碼來源:FuzzyTermEnum.cs

示例6: SingleTermEnum

 /// <summary>
 /// Creates a new <c>SingleTermEnum</c>.
 /// <p/>
 /// After calling the constructor the enumeration is already pointing to the term,
 ///  if it exists.
 /// </summary>
 public SingleTermEnum(IndexReader reader, Term singleTerm)
 {
     this.singleTerm = singleTerm;
     SetEnum(reader.Terms(singleTerm));
 }
開發者ID:mindis,項目名稱:Transformalize,代碼行數:11,代碼來源:SingleTermEnum.cs


注:本文中的Transformalize.Libs.Lucene.Net.Index.IndexReader.Terms方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。