当前位置: 首页>>代码示例>>C#>>正文


C# Lucene.Net.Index.IndexReader.Terms方法代码示例

本文整理汇总了C#中Lucene.Net.Index.IndexReader.Terms方法的典型用法代码示例。如果您正苦于以下问题:C# Lucene.Net.Index.IndexReader.Terms方法的具体用法?C# Lucene.Net.Index.IndexReader.Terms怎么用?C# Lucene.Net.Index.IndexReader.Terms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lucene.Net.Index.IndexReader的用法示例。


在下文中一共展示了Lucene.Net.Index.IndexReader.Terms方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RegexTermEnum

        public RegexTermEnum(IndexReader reader, Term term)
            : base()
        {
            field = term.Field();
            System.String text = term.Text();

            pattern = new Pattern(text);

            // Find the first regex character position, to find the
            // maximum prefix to use for term enumeration
            int index = 0;
            while (index < text.Length)
            {
                char c = text[index];

                if (!System.Char.IsLetterOrDigit(c))
                    break;

                index++;
            }

            pre = text.Substring(0, (index) - (0));

            SetEnum(reader.Terms(new Term(term.Field(), pre)));
        }
开发者ID:karino2,项目名称:wikipediaconv,代码行数:25,代码来源:RegexTermEnum.cs

示例2: CreateValue

			protected internal override System.Object CreateValue(IndexReader reader, System.Object entryKey)
			{
				Entry entry = (Entry) entryKey;
				System.String field = entry.field;
				LongParser parser = (LongParser) entry.custom;
				long[] retArray = new long[reader.MaxDoc()];
				TermDocs termDocs = reader.TermDocs();
				TermEnum termEnum = reader.Terms(new Term(field, ""));
				try
				{
					do 
					{
						Term term = termEnum.Term();
						if (term == null || (System.Object) term.Field() != (System.Object) field)
							break;
						long termval = parser.ParseLong(term.Text());
						termDocs.Seek(termEnum);
						while (termDocs.Next())
						{
							retArray[termDocs.Doc()] = termval;
						}
					}
					while (termEnum.Next());
				}
				finally
				{
					termDocs.Close();
					termEnum.Close();
				}
				return retArray;
			}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:31,代码来源:ExtendedFieldCacheImpl.cs

示例3: Rewrite

 public override Query Rewrite(IndexReader reader)
 {
     BooleanQuery query = new BooleanQuery(true);
     TermEnum enumerator = reader.Terms(prefix);
     try
     {
         System.String prefixText = prefix.Text();
         System.String prefixField = prefix.Field();
         do
         {
             Term term = enumerator.Term();
             if (term != null && term.Text().StartsWith(prefixText) && term.Field() == prefixField)
             {
                 TermQuery tq = new TermQuery(term); // found a match
                 tq.SetBoost(GetBoost()); // set the boost
                 query.Add(tq, BooleanClause.Occur.SHOULD); // add to query
                 //System.out.println("added " + term);
             }
             else
             {
                 break;
             }
         }
         while (enumerator.Next());
     }
     finally
     {
         enumerator.Close();
     }
     return query;
 }
开发者ID:kiichi7,项目名称:Search-Engine,代码行数:31,代码来源:PrefixQuery.cs

示例4: Rewrite

		public override Query Rewrite(IndexReader reader)
		{
			
			BooleanQuery query = new BooleanQuery(true);
			TermEnum enumerator = reader.Terms(lowerTerm);
			
			try
			{
				
				bool checkLower = false;
				if (!inclusive)
				// make adjustments to set to exclusive
					checkLower = true;
				
				System.String testField = GetField();
				
				do 
				{
					Term term = enumerator.Term();
					if (term != null && term.Field() == testField)
					{
						if (!checkLower || String.CompareOrdinal(term.Text(), lowerTerm.Text()) > 0)
						{
							checkLower = false;
							if (upperTerm != null)
							{
								int compare = String.CompareOrdinal(upperTerm.Text(), term.Text());
								/* if beyond the upper term, or is exclusive and
								* this is equal to the upper term, break out */
								if ((compare < 0) || (!inclusive && compare == 0))
									break;
							}
							TermQuery tq = new TermQuery(term); // found a match
							tq.SetBoost(GetBoost()); // set the boost
							query.Add(tq, BooleanClause.Occur.SHOULD); // add to query
						}
					}
					else
					{
						break;
					}
				}
				while (enumerator.Next());
			}
			finally
			{
				enumerator.Close();
			}
			return query;
		}
开发者ID:ArsenShnurkov,项目名称:beagle-1,代码行数:50,代码来源:RangeQuery.cs

示例5: 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:modulexcite,项目名称:Xamarin-Lucene.Net,代码行数:28,代码来源:WildcardTermEnum.cs

示例6: CreateValue

 protected internal override System.Object CreateValue(IndexReader reader, Entry entryKey)
 {
     Entry entry = (Entry) entryKey;
     System.String field = entry.field;
     SortComparator comparator = (SortComparator) entry.custom;
     System.IComparable[] retArray = new System.IComparable[reader.MaxDoc()];
     TermDocs termDocs = reader.TermDocs();
     TermEnum termEnum = reader.Terms(new Term(field));
     try
     {
         do
         {
             Term term = termEnum.Term();
             if (term == null || (System.Object) term.Field() != (System.Object) field)
                 break;
             System.IComparable termval = comparator.GetComparable(term.Text());
             termDocs.Seek(termEnum);
             while (termDocs.Next())
             {
                 retArray[termDocs.Doc()] = termval;
             }
         }
         while (termEnum.Next());
     }
     finally
     {
         termDocs.Close();
         termEnum.Close();
     }
     return retArray;
 }
开发者ID:andylaudotnet,项目名称:StockFoo,代码行数:31,代码来源:FieldCacheImpl.cs

示例7: GetAuto

		/// <summary>The pattern used to detect integer values in a field </summary>
		/// <summary>removed for java 1.3 compatibility
		/// protected static final Pattern pIntegers = Pattern.compile ("[0-9\\-]+");
		/// 
		/// </summary>
		
		/// <summary>The pattern used to detect float values in a field </summary>
		/// <summary> removed for java 1.3 compatibility
		/// protected static final Object pFloats = Pattern.compile ("[0-9+\\-\\.eEfFdD]+");
		/// </summary>
		
		// inherit javadocs
		public virtual System.Object GetAuto(IndexReader reader, System.String field)
		{
			field = String.Intern(field);
			System.Object ret = Lookup(reader, field, SortField.AUTO);
			if (ret == null)
			{
				TermEnum enumerator = reader.Terms(new Term(field, ""));
				try
				{
					Term term = enumerator.Term();
					if (term == null)
					{
						throw new System.SystemException("no terms in field " + field + " - cannot determine sort type");
					}
					if (term.Field() == field)
					{
						System.String termtext = term.Text().Trim();
						
						/**
						* Java 1.4 level code:
						
						if (pIntegers.matcher(termtext).matches())
						return IntegerSortedHitQueue.comparator (reader, enumerator, field);
						
						else if (pFloats.matcher(termtext).matches())
						return FloatSortedHitQueue.comparator (reader, enumerator, field);
						*/
						
						// Java 1.3 level code:
						try
						{
							System.Int32.Parse(termtext);
							ret = GetInts(reader, field);
						}
						catch (System.FormatException nfe1)
						{
							try
							{
								System.Single.Parse(termtext);
								ret = GetFloats(reader, field);
							}
							catch (System.FormatException nfe2)
							{
								ret = GetStringIndex(reader, field);
							}
						}
						if (ret != null)
						{
							Store(reader, field, SortField.AUTO, ret);
						}
					}
					else
					{
						throw new System.SystemException("field \"" + field + "\" does not appear to be indexed");
					}
				}
				finally
				{
					enumerator.Close();
				}
			}
			return ret;
		}
开发者ID:ArsenShnurkov,项目名称:beagle-1,代码行数:75,代码来源:FieldCacheImpl.cs

示例8: CreateValue

 protected internal override System.Object CreateValue(IndexReader reader, Entry entryKey)
 {
     System.String field = StringHelper.Intern(entryKey.field);
     System.String[] retArray = new System.String[reader.MaxDoc];
     TermDocs termDocs = reader.TermDocs();
     TermEnum termEnum = reader.Terms(new Term(field));
     try
     {
         do 
         {
             Term term = termEnum.Term;
             if (term == null || (System.Object) term.Field != (System.Object) field)
                 break;
             System.String termval = term.Text;
             termDocs.Seek(termEnum);
             while (termDocs.Next())
             {
                 retArray[termDocs.Doc] = termval;
             }
         }
         while (termEnum.Next());
     }
     finally
     {
         termDocs.Close();
         termEnum.Close();
     }
     return retArray;
 }
开发者ID:Nangal,项目名称:lucene.net,代码行数:29,代码来源:FieldCacheImpl.cs

示例9: CreateValue

 protected internal override object CreateValue(IndexReader reader, object fieldKey)
 {
     System.String field = String.Intern(((System.String) fieldKey));
     System.String[] retArray = new System.String[reader.MaxDoc()];
     TermDocs termDocs = reader.TermDocs();
     TermEnum termEnum = reader.Terms(new Term(field));
     try
     {
         do
         {
             Term term = termEnum.Term();
             if (term == null || (object) term.Field() != (object) field)
                 break;
             System.String termval = term.Text();
             termDocs.Seek(termEnum);
             while (termDocs.Next())
             {
                 retArray[termDocs.Doc()] = termval;
             }
         }
         while (termEnum.Next());
     }
     finally
     {
         termDocs.Close();
         termEnum.Close();
     }
     return retArray;
 }
开发者ID:cqm0609,项目名称:lucene-file-finder,代码行数:29,代码来源:FieldCacheImpl.cs

示例10: NewComparator

			public virtual ScoreDocComparator NewComparator(IndexReader reader, System.String fieldname)
			{
				System.String field = String.Intern(fieldname);
				TermEnum enumerator = reader.Terms(new Term(fieldname, ""));
				try
				{
					return new AnonymousClassScoreDocComparator(reader, enumerator, field, this);
				}
				finally
				{
					enumerator.Close();
				}
			}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:13,代码来源:SampleComparable.cs

示例11: Generate

		public virtual void  Generate(IndexReader reader)
		{
			TermEnum enumerator = reader.Terms(prefix);
			TermDocs termDocs = reader.TermDocs();
			
			try
			{
				
				System.String prefixText = prefix.Text();
				System.String prefixField = prefix.Field();
				do 
				{
					Term term = enumerator.Term();
					if (term != null && term.Text().StartsWith(prefixText) && (System.Object) term.Field() == (System.Object) prefixField)
					{
						termDocs.Seek(term);
						while (termDocs.Next())
						{
							HandleDoc(termDocs.Doc());
						}
					}
					else
					{
						break;
					}
				}
				while (enumerator.Next());
			}
			finally
			{
				termDocs.Close();
				enumerator.Close();
			}
		}
开发者ID:zweib730,项目名称:beagrep,代码行数:34,代码来源:PrefixFilter.cs

示例12: Bits

		/// <summary> Returns a BitSet with true for documents which should be
		/// permitted in search results, and false for those that should
		/// not.
		/// </summary>
		public override System.Collections.BitArray Bits(IndexReader reader)
		{
			System.Collections.BitArray bits = new System.Collections.BitArray((reader.MaxDoc() % 64 == 0?reader.MaxDoc() / 64:reader.MaxDoc() / 64 + 1) * 64);
			TermEnum enumerator = reader.Terms(new Term(field, start));
			TermDocs termDocs = reader.TermDocs();
			if (enumerator.Term() == null)
			{
				return bits;
			}
			
			try
			{
				Term stop = new Term(field, end);
				while (enumerator.Term().CompareTo(stop) <= 0)
				{
					termDocs.Seek(enumerator.Term());
					while (termDocs.Next())
					{
						bits.Set(termDocs.Doc(), true);
					}
					if (!enumerator.Next())
					{
						break;
					}
				}
			}
			finally
			{
				enumerator.Close();
				termDocs.Close();
			}
			return bits;
		}
开发者ID:ArsenShnurkov,项目名称:beagle-1,代码行数:37,代码来源:DateFilter.cs

示例13: PrefixTermEnum

		public PrefixTermEnum(IndexReader reader, Term prefix)
		{
			this.prefix = prefix;
			
			SetEnum(reader.Terms(new Term(prefix.Field, prefix.Text)));
		}
开发者ID:modulexcite,项目名称:Xamarin-Lucene.Net,代码行数:6,代码来源:PrefixTermEnum.cs

示例14: Rewrite

        public override Query Rewrite(IndexReader reader)
        {
            BooleanQuery query = new BooleanQuery(true);
            string testField = GetField();
            if (collator != null)
            {
                TermEnum enumerator = reader.Terms(new Term(testField, ""));
                string lowerTermText = lowerTerm != null ? lowerTerm.Text() : null;
                string upperTermText = upperTerm != null ? upperTerm.Text() : null;

                try
                {
                    do
                    {
                        Term term = enumerator.Term();
                        if (term != null && term.Field() == testField) // interned comparison
                        {
                            if ((lowerTermText == null ||
                                (inclusive ? collator.Compare(term.Text(), lowerTermText) >= 0 : collator.Compare(term.Text(), lowerTermText) > 0))
                                &&
                                (upperTermText == null ||
                                (inclusive ? collator.Compare(term.Text(), upperTermText) <= 0 : collator.Compare(term.Text(), upperTermText) < 0))
                                )
                            {
                                AddTermToQuery(term, query);
                            }
                        }
                    }
                    while (enumerator.Next());
                }
                finally
                {
                    enumerator.Close();
                }
            }
            else
            {
                TermEnum enumerator = reader.Terms(lowerTerm);

                try
                {

                    bool checkLower = false;
                    if (!inclusive)
                        // make adjustments to set to exclusive
                        checkLower = true;

                    do
                    {
                        Term term = enumerator.Term();
                        if (term != null && term.Field() == testField)
                        {
                            // interned comparison
                            if (!checkLower || String.CompareOrdinal(term.Text(), lowerTerm.Text()) > 0)
                            {
                                checkLower = false;
                                if (upperTerm != null)
                                {
                                    int compare = String.CompareOrdinal(upperTerm.Text(), term.Text());
                                    /* if beyond the upper term, or is exclusive and
                                    * this is equal to the upper term, break out */
                                    if ((compare < 0) || (!inclusive && compare == 0))
                                        break;
                                }
                                AddTermToQuery(term, query); // Found a match
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                    while (enumerator.Next());
                }
                finally
                {
                    enumerator.Close();
                }
            }
            return query;
        }
开发者ID:cqm0609,项目名称:lucene-file-finder,代码行数:81,代码来源:RangeQuery.cs

示例15: CreateValue

 protected internal override System.Object CreateValue(IndexReader reader, Entry entryKey)
 {
     Entry entry = (Entry) entryKey;
     System.String field = entry.field;
     ByteParser parser = (ByteParser) entry.custom;
     if (parser == null)
     {
         return wrapper.GetBytes(reader, field, Lucene.Net.Search.FieldCache_Fields.DEFAULT_BYTE_PARSER);
     }
     byte[] retArray = new byte[reader.MaxDoc()];
     TermDocs termDocs = reader.TermDocs();
     TermEnum termEnum = reader.Terms(new Term(field));
     try
     {
         do
         {
             Term term = termEnum.Term();
             if (term == null || (System.Object) term.Field() != (System.Object) field)
                 break;
             byte termval = parser.ParseByte(term.Text());
             termDocs.Seek(termEnum);
             while (termDocs.Next())
             {
                 retArray[termDocs.Doc()] = termval;
             }
         }
         while (termEnum.Next());
     }
     catch (StopFillCacheException stop)
     {
     }
     finally
     {
         termDocs.Close();
         termEnum.Close();
     }
     return retArray;
 }
开发者ID:BackupTheBerlios,项目名称:lyra2-svn,代码行数:38,代码来源:FieldCacheImpl.cs


注:本文中的Lucene.Net.Index.IndexReader.Terms方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。