• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Index.Term类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Main

		public static void  Main(System.String[] args)
		{
			System.String usage = typeof(DeleteFiles) + " <unique_term>";
			if (args.Length == 0)
			{
				System.Console.Error.WriteLine("Usage: " + usage);
				System.Environment.Exit(1);
			}
			try
			{
				Directory directory = FSDirectory.Open("index");
				IndexReader reader = IndexReader.Open(directory, false); // we don't want read-only because we are about to delete
				
				Term term = new Term("path", args[0]);
				int deleted = reader.DeleteDocuments(term);
				
				System.Console.Out.WriteLine("deleted " + deleted + " documents containing " + term);
				
				// one can also delete documents by their internal id:
				/*
				for (int i = 0; i < reader.maxDoc(); i++) {
				System.out.println("Deleting document with id " + i);
				reader.delete(i);
				}*/
				
				reader.Close();
				directory.Close();
			}
			catch (System.Exception e)
			{
				System.Console.Out.WriteLine(" caught a " + e.GetType() + "\n with message: " + e.Message);
			}
		}
开发者ID:synhershko,项目名称:lucene.net,代码行数:33,代码来源:DeleteFiles.cs


示例2: Read

 public void Read(IndexInput input, FieldInfos fieldInfos)
 {
     this.Term = null; // invalidate cache
     NewSuffixStart = input.ReadVInt();
     int length = input.ReadVInt();
     int totalLength = NewSuffixStart + length;
     Debug.Assert(totalLength <= ByteBlockPool.BYTE_BLOCK_SIZE - 2, "termLength=" + totalLength + ",resource=" + input);
     if (Bytes.Bytes.Length < totalLength)
     {
         Bytes.Grow(totalLength);
     }
     Bytes.Length = totalLength;
     input.ReadBytes(Bytes.Bytes, NewSuffixStart, length);
     int fieldNumber = input.ReadVInt();
     if (fieldNumber != CurrentFieldNumber)
     {
         CurrentFieldNumber = fieldNumber;
         // NOTE: too much sneakiness here, seriously this is a negative vint?!
         if (CurrentFieldNumber == -1)
         {
             Field = "";
         }
         else
         {
             Debug.Assert(fieldInfos.FieldInfo(CurrentFieldNumber) != null, CurrentFieldNumber.ToString());
             Field = String.Intern(fieldInfos.FieldInfo(CurrentFieldNumber).Name);
         }
     }
     else
     {
         Debug.Assert(Field.Equals(fieldInfos.FieldInfo(fieldNumber).Name), "currentFieldNumber=" + CurrentFieldNumber + " field=" + Field + " vs " + fieldInfos.FieldInfo(fieldNumber) == null ? "null" : fieldInfos.FieldInfo(fieldNumber).Name);
     }
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:33,代码来源:TermBuffer.cs


示例3: TermSpans

		public TermSpans(TermPositions positions, Term term)
		{
			
			this.positions = positions;
			this.term = term;
			doc = - 1;
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:7,代码来源:TermSpans.cs


示例4: WildcardQuery

 public WildcardQuery(Term term)
     : base(term)
 {
     //will be removed in 3.0
     this.term = term;
     this.termContainsWildcard = (term.Text().IndexOf('*') != - 1) || (term.Text().IndexOf('?') != - 1);
 }
开发者ID:BackupTheBerlios,项目名称:lyra2-svn,代码行数:7,代码来源:WildcardQuery.cs


示例5: Close

 /// <summary>Closes the enumeration to further activity, freeing resources.  </summary>
 public override void Close()
 {
     if (actualEnum != null)
         actualEnum.Close();
     currentTerm = null;
     actualEnum = null;
 }
开发者ID:BackupTheBerlios,项目名称:lyra2-svn,代码行数:8,代码来源:FilteredTermEnum.cs


示例6: TermSpans

		public TermSpans(TermPositions positions, Term term)
		{
			
			this.internalPositions = positions;
			this.term = term;
			internalDoc = - 1;
		}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:7,代码来源:TermSpans.cs


示例7: DocFreq

 public override int DocFreq(Term term)
 {
     int docFreq = 0;
     for (int i = 0; i < searchables.Length; i++)
         docFreq += searchables[i].DocFreq(term);
     return docFreq;
 }
开发者ID:vineelkovvuri,项目名称:ExtendableDesktopSearch,代码行数:7,代码来源:MultiSearcher.cs


示例8: 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


示例9: CreateRandomTerms

		public virtual void  CreateRandomTerms(int nDocs, int nTerms, double power, Directory dir)
		{
			int[] freq = new int[nTerms];
			for (int i = 0; i < nTerms; i++)
			{
				int f = (nTerms + 1) - i; // make first terms less frequent
				freq[i] = (int) System.Math.Ceiling(System.Math.Pow(f, power));
				terms[i] = new Term("f", System.Convert.ToString((char) ('A' + i)));
			}
			
			IndexWriter iw = new IndexWriter(dir, new WhitespaceAnalyzer(), true);
			for (int i = 0; i < nDocs; i++)
			{
				Document d = new Document();
				for (int j = 0; j < nTerms; j++)
				{
					if (r.Next(freq[j]) == 0)
					{
						d.Add(new Field("f", terms[j].Text(), Field.Store.NO, Field.Index.UN_TOKENIZED));
						//System.out.println(d);
					}
				}
				iw.AddDocument(d);
			}
			iw.Optimize();
			iw.Close();
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:27,代码来源:TestScorerPerf.cs


示例10: DocFreq

        /// <summary>
        /// Executes each <see cref="Searchable"/>'s docFreq() in its own thread and 
        /// waits for each search to complete and merge the results back together.
        /// </summary>
        public override int DocFreq(Term term)
        {
            int[] results = new int[searchables.Length];
            Parallel.For(0, searchables.Length, (i) => results[i] = searchables[i].DocFreq(term));

            return results.Sum();
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:11,代码来源:ParallelMultiSearcher.cs


示例11: Add

		/// <summary>Add multiple terms at the next position in the phrase.  Any of the terms
		/// may match.
		/// 
		/// </summary>
		/// <seealso cref="PhraseQuery.Add(Term)">
		/// </seealso>
		public virtual void  Add(Term[] terms)
		{
			int position = 0;
			if (positions.Count > 0)
				position = ((System.Int32) positions[positions.Count - 1]) + 1;
			
			Add(terms, position);
		}
开发者ID:ArsenShnurkov,项目名称:beagle-1,代码行数:14,代码来源:PhrasePrefixQuery.cs


示例12: Add

	    /// <summary> Adds a term to the end of the query phrase.
		/// The relative position of the term is the one immediately after the last term added.
		/// </summary>
		public virtual void  Add(Term term)
		{
			int position = 0;
			if (positions.Count > 0)
				position = positions[positions.Count - 1] + 1;
			
			Add(term, position);
		}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:11,代码来源:PhraseQuery.cs


示例13: 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


示例14: TermCompare

	    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:modulexcite,项目名称:Xamarin-Lucene.Net,代码行数:9,代码来源:PrefixTermEnum.cs


示例15: DocFreqs

 // inherit javadoc
 public virtual int[] DocFreqs(Term[] terms)
 {
     int[] result = new int[terms.Length];
     for (int i = 0; i < terms.Length; i++)
     {
         result[i] = DocFreq(terms[i]);
     }
     return result;
 }
开发者ID:cqm0609,项目名称:lucene-file-finder,代码行数:10,代码来源:Searcher.cs


示例16: WildcardQuery

		public WildcardQuery(Term term)
		{ 
			this.internalTerm = term;
		    string text = term.Text;
		    _termContainsWildcard = (term.Text.IndexOf('*') != -1)
		                                || (term.Text.IndexOf('?') != -1);
		    _termIsPrefix = _termContainsWildcard
		                        && (text.IndexOf('?') == -1)
		                        && (text.IndexOf('*') == text.Length - 1);
		}
开发者ID:modulexcite,项目名称:Xamarin-Lucene.Net,代码行数:10,代码来源:WildcardQuery.cs


示例17: SetEnum

		/// <summary> use this method to set the actual TermEnum (e.g. in ctor),
		/// it will be automatically positioned on the first matching term.
		/// </summary>
		protected internal virtual void  SetEnum(TermEnum actualEnum)
		{
			this.actualEnum = actualEnum;
			// Find the first term that matches
			Term term = actualEnum.Term;
			if (term != null && TermCompare(term))
				currentTerm = term;
			else
				Next();
		}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:13,代码来源:FilteredTermEnum.cs


示例18: 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:karino2,项目名称:wikipediaconv,代码行数:22,代码来源:PhraseQuery.cs


示例19: WildcardEquals

	    /*protected internal*/ 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 WildcardEquals(text, 0, searchText, preLen);
				}
			}
			endEnum = true;
			return false;
		}
开发者ID:modulexcite,项目名称:Xamarin-Lucene.Net,代码行数:13,代码来源:WildcardTermEnum.cs


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Search.IndexSearcher类代码示例发布时间:2022-05-24
下一篇:
C# Index.RandomIndexWriter类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap