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


C# Lucene.Net.Index.Term.Field方法代码示例

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


在下文中一共展示了Lucene.Net.Index.Term.Field方法的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: TermCompare

		public /*protected internal*/ override bool TermCompare(Term term)
		{
			if ((System.Object) term.Field() == (System.Object) prefix.Field() && term.Text().StartsWith(prefix.Text()))
			{
				return true;
			}
			endEnum = true;
			return false;
		}
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:9,代码来源:PrefixTermEnum.cs

示例3: TermCompare

		protected internal override bool TermCompare(Term term)
		{
			if ((System.Object) field == (System.Object) term.Field())
			{
				System.String searchText = term.Text();
				if (searchText.StartsWith(pre))
				{
                    return pattern.Match(searchText).Success;
				}
			}
			endEnum = true;
			return false;
		}
开发者ID:ArsenShnurkov,项目名称:beagle-1,代码行数:13,代码来源:RegexTermEnum.cs

示例4: TermCompare

		protected internal override bool TermCompare(Term term)
		{
			if (field == term.Field())
			{
				System.String searchText = term.Text();
				if (searchText.StartsWith(pre))
				{
					return WildcardEquals(text, 0, searchText, preLen);
				}
			}
			endEnum = true;
			return false;
		}
开发者ID:ArsenShnurkov,项目名称:beagle-1,代码行数:13,代码来源:WildcardTermEnum.cs

示例5: WildcardTermEnum

		/// <summary> Creates a new <code>WildcardTermEnum</code>.  Passing in a
		/// {@link Lucene.Net.index.Term Term} that does not contain a
		/// <code>WILDCARD_CHAR</code> will cause an exception to be thrown.
		/// <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();
			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:ArsenShnurkov,项目名称:beagle-1,代码行数:30,代码来源:WildcardTermEnum.cs

示例6: RangeQuery

        /// <summary>Constructs a query selecting all terms greater than
        /// <code>lowerTerm</code> but less than <code>upperTerm</code>.
        /// There must be at least one term and either term may be null,
        /// in which case there is no bound on that side, but if there are
        /// two terms, both terms <b>must</b> be for the same field.
        /// </summary>
        public RangeQuery(Term lowerTerm, Term upperTerm, bool inclusive)
        {
            if (lowerTerm == null && upperTerm == null)
            {
                throw new System.ArgumentException("At least one term must be non-null");
            }
            if (lowerTerm != null && upperTerm != null && lowerTerm.Field() != upperTerm.Field())
            {
                throw new System.ArgumentException("Both terms must be for the same field");
            }

            // if we have a lowerTerm, start there. otherwise, start at beginning
            if (lowerTerm != null)
            {
                this.lowerTerm = lowerTerm;
            }
            else
            {
                this.lowerTerm = new Term(upperTerm.Field(), "");
            }

            this.upperTerm = upperTerm;
            this.inclusive = inclusive;
        }
开发者ID:karino2,项目名称:wikipediaconv,代码行数:30,代码来源:RangeQuery.cs

示例7: MoveNext

 public bool MoveNext()
 {
     has_next_called = true;
     try
     {
         // if there is still words
         if (!termEnum.Next())
         {
             actualTerm = null;
             return false;
         }
         //  if the next word are in the field
         actualTerm = termEnum.Term();
         System.String fieldt = actualTerm.Field();
         if ( fieldt != Enclosing_Instance.field)
         {
             actualTerm = null;
             return false;
         }
         return true;
     }
     catch (System.IO.IOException ex)
     {
         System.Console.Error.WriteLine(ex.StackTrace);
         return false;
     }
 }
开发者ID:Rationalle,项目名称:ravendb,代码行数:27,代码来源:LuceneDictionary.cs

示例8: Add

		/// <summary> Adds a term to the end of the query phrase.
		/// The relative position of the term within the phrase is specified explicitly.
		/// This allows e.g. phrases with more than one term at the same position
		/// or phrases with gaps (e.g. in connection with stopwords).
		/// 
		/// </summary>
		/// <param name="">term
		/// </param>
		/// <param name="">position
		/// </param>
		public virtual void  Add(Term term, int position)
		{
			if (terms.Count == 0)
				field = term.Field();
			else if (term.Field() != field)
			{
				throw new System.ArgumentException("All phrase terms must be in the same field: " + term);
			}
			
			terms.Add(term);
			positions.Add((System.Int32) position);
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:22,代码来源:PhraseQuery.cs

示例9: TermCompare

 /// <summary> The termCompare method in FuzzyTermEnum uses Levenshtein distance to 
 /// calculate the distance between the given term and the comparing term. 
 /// </summary>
 /*protected internal*/
 public override bool TermCompare(Term term)
 {
     if ((System.Object) field == (System.Object) term.Field() && term.Text().StartsWith(prefix))
     {
         System.String target = term.Text().Substring(prefix.Length);
         this.similarity = Similarity(target);
         return (similarity > minimumSimilarity);
     }
     endEnum = true;
     return false;
 }
开发者ID:BackupTheBerlios,项目名称:lyra2-svn,代码行数:15,代码来源:FuzzyTermEnum.cs

示例10: 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>.
        /// <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));

            InitializeMaxDistances();
            this.d = InitDistanceArray();

            SetEnum(reader.Terms(new Term(searchTerm.Field(), prefix)));
        }
开发者ID:BackupTheBerlios,项目名称:lyra2-svn,代码行数:45,代码来源:FuzzyTermEnum.cs

示例11: TermCompare

		public /*protected internal*/ override bool TermCompare(Term term)
		{
			if (collator == null)
			{
				// Use Unicode code point ordering
				bool checkLower = false;
				if (!includeLower)
				// make adjustments to set to exclusive
					checkLower = true;
				if (term != null && (System.Object) term.Field() == (System.Object) field)
				{
					// interned comparison
					if (!checkLower || null == lowerTermText || String.CompareOrdinal(term.Text(), lowerTermText) > 0)
					{
						checkLower = false;
						if (upperTermText != null)
						{
							int compare = String.CompareOrdinal(upperTermText, term.Text());
							/*
							* if beyond the upper term, or is exclusive and this is equal to
							* the upper term, break out
							*/
							if ((compare < 0) || (!includeUpper && compare == 0))
							{
								endEnum = true;
								return false;
							}
						}
						return true;
					}
				}
				else
				{
					// break
					endEnum = true;
					return false;
				}
				return false;
			}
			else
			{
				if (term != null && (System.Object) term.Field() == (System.Object) field)
				{
					// interned comparison
					if ((lowerTermText == null || (includeLower?collator.Compare(term.Text().ToString(), lowerTermText.ToString()) >= 0:collator.Compare(term.Text().ToString(), lowerTermText.ToString()) > 0)) && (upperTermText == null || (includeUpper?collator.Compare(term.Text().ToString(), upperTermText.ToString()) <= 0:collator.Compare(term.Text().ToString(), upperTermText.ToString()) < 0)))
					{
						return true;
					}
					return false;
				}
				endEnum = true;
				return false;
			}
		}
开发者ID:VirtueMe,项目名称:ravendb,代码行数:54,代码来源:TermRangeTermEnum.cs

示例12: MoveNext

            //hasNext()
            public bool MoveNext()
            {
                hasNextCalled = true;
                
                actualTerm = termEnum.Term();

                // if there are no words return false
                if (actualTerm == null) return false;

                System.String fieldt = actualTerm.Field();
                termEnum.Next();

                // if the next word doesn't have the same field return false
                if (fieldt != enclosingInstance.field)
                {
                    actualTerm = null;
                    return false;
                }
                return true;
            }
开发者ID:Mpdreamz,项目名称:lucene.net,代码行数:21,代码来源:LuceneDictionary.cs

示例13: TermCompare

 /// <summary> Compares if current upper bound is reached,
 /// this also updates the term count for statistics.
 /// In contrast to <see cref="FilteredTermEnum" />, a return value
 /// of <c>false</c> ends iterating the current enum
 /// and forwards to the next sub-range.
 /// </summary>
 //@Override
 /*protected internal*/
 public override bool TermCompare(Term term)
 {
     return ((System.Object) term.Field() == (System.Object) Enclosing_Instance.field && String.CompareOrdinal(term.Text(), currentUpperBound) <= 0);
 }
开发者ID:sinsay,项目名称:SSE,代码行数:12,代码来源:NumericRangeQuery.cs

示例14: RangeQuery

        /// <summary>Constructs a query selecting all terms greater than
        /// <c>lowerTerm</c> but less than <c>upperTerm</c>.
        /// There must be at least one term and either term may be null,
        /// in which case there is no bound on that side, but if there are
        /// two terms, both terms <b>must</b> be for the same field.
        /// <p/>
        /// If <c>collator</c> is not null, it will be used to decide whether
        /// index terms are within the given range, rather than using the Unicode code
        /// point order in which index terms are stored.
        /// <p/>
        /// <strong>WARNING:</strong> Using this constructor and supplying a non-null
        /// value in the <c>collator</c> parameter will cause every single 
        /// index Term in the Field referenced by lowerTerm and/or upperTerm to be
        /// examined.  Depending on the number of index Terms in this Field, the 
        /// operation could be very slow.
        /// 
        /// </summary>
        /// <param name="lowerTerm">The Term at the lower end of the range
        /// </param>
        /// <param name="upperTerm">The Term at the upper end of the range
        /// </param>
        /// <param name="inclusive">If true, both <c>lowerTerm</c> and
        /// <c>upperTerm</c> will themselves be 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>
        public RangeQuery(Term lowerTerm, Term upperTerm, bool inclusive, System.Globalization.CompareInfo collator)
        {
            if (lowerTerm == null && upperTerm == null)
                throw new System.ArgumentException("At least one term must be non-null");
            if (lowerTerm != null && upperTerm != null && (System.Object) lowerTerm.Field() != (System.Object) upperTerm.Field())
                throw new System.ArgumentException("Both terms must have the same field");

            delegate_Renamed = new TermRangeQuery((lowerTerm == null)?upperTerm.Field():lowerTerm.Field(), (lowerTerm == null)?null:lowerTerm.Text(), (upperTerm == null)?null:upperTerm.Text(), inclusive, inclusive, collator);
            delegate_Renamed.SetRewriteMethod(TermRangeQuery.SCORING_BOOLEAN_QUERY_REWRITE);
        }
开发者ID:sinsay,项目名称:SSE,代码行数:38,代码来源:RangeQuery.cs

示例15: PrefixTermEnum

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


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