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


C# Monodoc.Terms方法代码示例

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


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

示例1: Rewrite

		public override Query Rewrite(Monodoc.Lucene.Net.Index.IndexReader reader)
		{
			BooleanQuery query = new BooleanQuery();
			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) && (System.Object) term.Field() == (System.Object) prefixField)
					{
						TermQuery tq = new TermQuery(term); // found a match
						tq.SetBoost(GetBoost()); // set the boost
						query.Add(tq, false, false); // add to query
						//System.out.println("added " + term);
					}
					else
					{
						break;
					}
				}
				while (enumerator.Next());
			}
			finally
			{
				enumerator.Close();
			}
			return query;
		}
开发者ID:emtees,项目名称:old-code,代码行数:31,代码来源:PrefixQuery.cs

示例2: Rewrite

		/// <summary> FIXME: Describe <code>rewrite</code> method here.
		/// 
		/// </summary>
		/// <param name="reader">an <code>Monodoc.Lucene.Net.Index.IndexReader</code> value
		/// </param>
		/// <returns> a <code>Query</code> value
		/// </returns>
		/// <exception cref=""> IOException if an error occurs
		/// </exception>
		public override Query Rewrite(Monodoc.Lucene.Net.Index.IndexReader reader)
		{
			
			BooleanQuery query = new BooleanQuery();
			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 && (System.Object) term.Field() == (System.Object) 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, false, false); // add to query
						}
					}
					else
					{
						break;
					}
				}
				while (enumerator.Next());
			}
			finally
			{
				enumerator.Close();
			}
			return query;
		}
开发者ID:emtees,项目名称:old-code,代码行数:59,代码来源:RangeQuery.cs

示例3: WildcardTermEnum

		/// <summary> Creates a new <code>WildcardTermEnum</code>.  Passing in a
		/// {@link Monodoc.Lucene.Net.Index.Term Term} that does not contain a
		/// <code>WILDCARD_CHAR</code> will cause an exception to be thrown.
		/// </summary>
		public WildcardTermEnum(Monodoc.Lucene.Net.Index.IndexReader reader, Term term):base()
		{
			searchTerm = term;
			field = searchTerm.Field();
			text = searchTerm.Text();
			
			int sidx = text.IndexOf((System.Char) WILDCARD_STRING);
			int cidx = text.IndexOf((System.Char) WILDCARD_CHAR);
			int idx = sidx;
			if (idx == - 1)
			{
				idx = cidx;
			}
			else if (cidx >= 0)
			{
				idx = System.Math.Min(idx, cidx);
			}
			
			pre = searchTerm.Text().Substring(0, (idx) - (0));
			preLen = pre.Length;
			text = text.Substring(preLen);
			SetEnum(reader.Terms(new Term(searchTerm.Field(), pre)));
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:27,代码来源:WildcardTermEnum.cs

示例4: FuzzyTermEnum

 /// <summary> Constructor for enumeration of all terms from specified <code>reader</code> which share a prefix of
 /// length <code>prefixLength</code> with <code>term</code> and which have a fuzzy similarity &gt;
 /// <code>minSimilarity</code>. 
 /// 
 /// </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(Monodoc.Lucene.Net.Index.IndexReader reader, Term term, float minSimilarity, int prefixLength):base()
 {
     InitBlock();
     minimumSimilarity = minSimilarity;
     scale_factor = 1.0f / (1.0f - minimumSimilarity);
     searchTerm = term;
     field = searchTerm.Field();
     text = searchTerm.Text();
     textlen = text.Length;
     if (prefixLength > 0 && prefixLength < textlen)
     {
         this.prefixLength = prefixLength;
         prefix = text.Substring(0, (prefixLength) - (0));
         text = text.Substring(prefixLength);
         textlen = text.Length;
     }
     SetEnum(reader.Terms(new Term(searchTerm.Field(), prefix)));
 }
开发者ID:emtees,项目名称:old-code,代码行数:32,代码来源:FuzzyTermEnum.cs

示例5: 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(Monodoc.Lucene.Net.Index.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:calumjiao,项目名称:Mono-Class-Libraries,代码行数:37,代码来源:DateFilter.cs

示例6: GetCustom

		// inherit javadocs
		public virtual System.IComparable[] GetCustom(Monodoc.Lucene.Net.Index.IndexReader reader, System.String field, SortComparator comparator)
		{
			field = String.Intern(field);
			System.Object ret = Lookup(reader, field, comparator);
			if (ret == null)
			{
				System.IComparable[] retArray = new System.IComparable[reader.MaxDoc()];
				if (retArray.Length > 0)
				{
					TermDocs termDocs = reader.TermDocs();
					TermEnum termEnum = reader.Terms(new Term(field, ""));
					try
					{
						if (termEnum.Term() == null)
						{
							throw new System.SystemException("no terms in Field " + field);
						}
						do 
						{
							Term term = termEnum.Term();
							if ((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();
					}
				}
				Store(reader, field, SortField.CUSTOM, retArray);
				return retArray;
			}
			return (System.IComparable[]) ret;
		}
开发者ID:emtees,项目名称:old-code,代码行数:43,代码来源: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(Monodoc.Lucene.Net.Index.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 ((System.Object) term.Field() == (System.Object) field)
					{
						System.String termtext = term.Text().Trim();
						
						/// <summary> 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);
						/// </summary>
						
						// 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:emtees,项目名称:old-code,代码行数:72,代码来源:FieldCacheImpl.cs

示例8: GetStringIndex

		// inherit javadocs
		public virtual StringIndex GetStringIndex(Monodoc.Lucene.Net.Index.IndexReader reader, System.String field)
		{
			field = String.Intern(field);
			System.Object ret = Lookup(reader, field, Monodoc.Lucene.Net.Search.FieldCache_Fields.STRING_INDEX);
			if (ret == null)
			{
				int[] retArray = new int[reader.MaxDoc()];
				System.String[] mterms = new System.String[reader.MaxDoc() + 1];
				if (retArray.Length > 0)
				{
					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
					{
						if (termEnum.Term() == null)
						{
							throw new System.SystemException("no terms in Field " + field);
						}
						do 
						{
							Term term = termEnum.Term();
							if ((System.Object) term.Field() != (System.Object) field)
								break;
							
							// store term text
							// we expect that there is at most one term per document
							if (t >= mterms.Length)
								throw new System.SystemException("there are more terms than documents in Field \"" + field + "\"");
							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);
				Store(reader, field, Monodoc.Lucene.Net.Search.FieldCache_Fields.STRING_INDEX, value_Renamed);
				return value_Renamed;
			}
			return (StringIndex) ret;
		}
开发者ID:emtees,项目名称:old-code,代码行数:76,代码来源:FieldCacheImpl.cs

示例9: GetFloats

		// inherit javadocs
		public virtual float[] GetFloats(Monodoc.Lucene.Net.Index.IndexReader reader, System.String field)
		{
			field = String.Intern(field);
			System.Object ret = Lookup(reader, field, SortField.FLOAT);
			if (ret == null)
			{
				float[] retArray = new float[reader.MaxDoc()];
				if (retArray.Length > 0)
				{
					TermDocs termDocs = reader.TermDocs();
					TermEnum termEnum = reader.Terms(new Term(field, ""));
                    try
                    {
                        if (termEnum.Term() == null)
                        {
                            throw new System.SystemException("no terms in Field " + field);
                        }
                        do 
                        {
                            Term term = termEnum.Term();
                            if ((System.Object) term.Field() != (System.Object) field)
                                break;
                            float termval;
                            try
                            {
                                termval = SupportClass.Single.Parse(term.Text());
                            }
                            catch (Exception e)
                            {
                                termval = 0;
                            }
                            termDocs.Seek(termEnum);
                            while (termDocs.Next())
                            {
                                retArray[termDocs.Doc()] = termval;
                            }
                        }
                        while (termEnum.Next());
                    }
                    finally
                    {
                        termDocs.Close();
                        termEnum.Close();
                    }
				}
				Store(reader, field, SortField.FLOAT, retArray);
				return retArray;
			}
			return (float[]) ret;
		}
开发者ID:emtees,项目名称:old-code,代码行数:51,代码来源:FieldCacheImpl.cs


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