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


C# StandardAnalyzer.Close方法代码示例

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


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

示例1: PerformExplain

        /// <summary>
        /// Performs the explanation.
        /// </summary>
        /// <param name="luceneVersion">The lucene version.</param>
        /// <param name="fsDirectory">The fs directory.</param>
        /// <param name="searchQuery">The search query.</param>
        /// <param name="resultId">The result identifier.</param>
        /// <returns></returns>
        protected virtual string PerformExplain(Version luceneVersion, FSDirectory fsDirectory, string searchQuery, int resultId)
		{
			/*
			 * The obvious problem here is that we're not using the exact same search as the real one.
			 */

			var explanation = string.Empty;

			using (var indexSearcher = new IndexSearcher(fsDirectory, false))
			{
				var analyzer = new StandardAnalyzer(luceneVersion);
				
				var queryParser = new MultiFieldQueryParser(luceneVersion, new[] { "Id".ToLowerInvariant() }, analyzer)
									{
										DefaultOperator = QueryParser.Operator.AND
									};
				
				var query = this.searchQueryParser.ParseQuery(searchQuery, queryParser);

				explanation = indexSearcher.Explain(query, resultId).ToHtml();

				analyzer.Close();
			}

			return explanation;
		}
开发者ID:KaraokeStu,项目名称:LeadPipe.Net,代码行数:34,代码来源:SearchScoreExplainer.cs

示例2: v

        public void v()
        {

            //Analyzer analyzer = new CJKAnalyzer();
            //TokenStream tokenStream = analyzer.TokenStream("", new StringReader("我爱你中国China中华人名共和国"));
            //Lucene.Net.Analysis.Token token = null;
            //while ((token = tokenStream.Next()) != null)
            //{
            //    Response.Write(token.TermText() + "<br/>");
            //}

            Lucene.Net.Analysis.Standard.StandardAnalyzer a = new Lucene.Net.Analysis.Standard.StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30);
            string s = "我日中华人民共和国";
            System.IO.StringReader reader = new System.IO.StringReader(s);
            Lucene.Net.Analysis.TokenStream ts = a.TokenStream(s, reader);
            bool hasnext = ts.IncrementToken();
            Lucene.Net.Analysis.Tokenattributes.ITermAttribute ita;
            while (hasnext)
            {
                ita = ts.GetAttribute<Lucene.Net.Analysis.Tokenattributes.ITermAttribute>();
                Console.WriteLine(ita.Term);
                hasnext = ts.IncrementToken();
            }
            ts.CloneAttributes();
            reader.Close();
            a.Close();
            Console.ReadKey();
        }
开发者ID:reckcn,项目名称:DevLib.Comm,代码行数:28,代码来源:Class1.cs

示例3: _search

		// main search method
		private static IEnumerable<SampleData> _search(string searchQuery, string searchField = "") {
			// validation
			if (string.IsNullOrEmpty(searchQuery.Replace("*", "").Replace("?", ""))) return new List<SampleData>();

			// set up lucene searcher
			using (var searcher = new IndexSearcher(_directory, false)) {
				var hits_limit = 1000;
				var analyzer = new StandardAnalyzer(Version.LUCENE_29);

				// search by single field
				if (!string.IsNullOrEmpty(searchField)) {
					var parser = new QueryParser(Version.LUCENE_29, searchField, analyzer);
					var query = parseQuery(searchQuery, parser);
					var hits = searcher.Search(query, hits_limit).ScoreDocs;
					var results = _mapLuceneToDataList(hits, searcher);
					analyzer.Close();
					searcher.Close();
					searcher.Dispose();
					return results;
				}
				// search by multiple fields (ordered by RELEVANCE)
				else {
					var parser = new MultiFieldQueryParser
						(Version.LUCENE_29, new[] {"Id", "Name", "Description"}, analyzer);
					var query = parseQuery(searchQuery, parser);
					var hits = searcher.Search(query, null, hits_limit, Sort.INDEXORDER).ScoreDocs;
					var results = _mapLuceneToDataList(hits, searcher);
					analyzer.Close();
					searcher.Close();
					searcher.Dispose();
					return results;
				}
			}
		}
开发者ID:CelticHarp,项目名称:Lucene.Net-search-MVC-sample-site,代码行数:35,代码来源:LuceneSearch.cs

示例4: AddUpdateLuceneIndex

        // add/update/clear search index data
        public static void AddUpdateLuceneIndex()
        {
            using (var context = new CreativeNetworkEntities())
            {

                // init lucene
                var analyzer = new StandardAnalyzer(Version.LUCENE_30);
                using (var writer = new IndexWriter(_directory, analyzer, IndexWriter.MaxFieldLength.UNLIMITED))
                {
                    // add data to lucene search index (replaces older entries if any)
                    foreach (var creative in context.Creative)
                    {
                        _addToLuceneIndex(creative, writer);
                        foreach (var chapter in creative.Chapter)
                        {
                            _addToLuceneIndex(chapter, writer);
                        }
                    }

                    // close handles
                    analyzer.Close();
                    writer.Dispose();
                }
            }
        }
开发者ID:JIy3AHKO,项目名称:CreativeNetwork,代码行数:26,代码来源:CreativeSearch.cs

示例5: BuildQuery

		public static Query BuildQuery(string query)
		{
			var untokenizedMatches = untokenizedQuery.Matches(query);
			var rangeMatches = rangeQuery.Matches(query);
		    var standardAnalyzer = new StandardAnalyzer(Version.LUCENE_29);
		    try
		    {
                if (untokenizedMatches.Count == 0 && rangeMatches.Count == 0)
                    return new QueryParser(Version.LUCENE_29, "", standardAnalyzer).Parse(query);
                var sb = new StringBuilder(query);
                var booleanQuery = new BooleanQuery();
                AddUntokenizedTerms(untokenizedMatches, booleanQuery, sb, query);
		    	AddRangeTerms(rangeMatches, booleanQuery, sb, query);
                var remaining = sb.ToString();
		    	remaining = hangingConditionAtStart.Replace(remaining, "");
		    	remaining = hangingConditionAtEnd.Replace(remaining, "");
				remaining = remaining.Trim();
		    	if (remaining.Length > 0)
                {
                    booleanQuery.Add(new QueryParser(Version.LUCENE_29, "", standardAnalyzer).Parse(remaining), BooleanClause.Occur.SHOULD);
                }
                return booleanQuery;
		    }
		    finally
		    {
		        standardAnalyzer.Close();
		    }
		}
开发者ID:VirtueMe,项目名称:ravendb,代码行数:28,代码来源:QueryBuilder.cs

示例6: _search

        private static IEnumerable<CustomerId> _search(string searchQuery)
        {
            // validation
            if (string.IsNullOrEmpty(searchQuery.Replace("*", "").Replace("?", ""))) return new List<CustomerId>();

            // set up lucene searcher
            using (var searcher = new IndexSearcher(_directory, false))
            {
                var hits_limit = 1000;
                var analyzer = new StandardAnalyzer(Version.LUCENE_29);

                {
                    //var query = new TermQuery(new Term("CustomerName", searchQuery));
                    var query = new BooleanQuery();
                    query.Add(new TermQuery(new Term("CustomerName", searchQuery)), Occur.MUST);
                    var hits = searcher.Search(query, hits_limit).ScoreDocs;
                    var results = _mapLuceneToDataList(hits, searcher);

                    analyzer.Close();
                    searcher.Dispose();
                    return results;
                }
                
            }
        }
开发者ID:jcwrequests,项目名称:Learning.Lucene.NET,代码行数:25,代码来源:CustomerIndexService.cs

示例7: Optimize

 public void Optimize()
 {
     var analyzer = new StandardAnalyzer(Version.LUCENE_30);
     using (var writer = new IndexWriter(Directory, analyzer, IndexWriter.MaxFieldLength.UNLIMITED))
     {
         analyzer.Close();
         writer.Optimize();
     }
 }
开发者ID:MikhailGogolushko,项目名称:lmsystem,代码行数:9,代码来源:BaseSearchMethod.cs

示例8: AddUpdateLuceneIndex

 public void AddUpdateLuceneIndex(IEnumerable<IPatient> sampleDatas)
 {
     var analyzer = new StandardAnalyzer(Version.LUCENE_30);
     using (var writer = new IndexWriter(_directory, analyzer, IndexWriter.MaxFieldLength.UNLIMITED))
     {
         foreach (var sampleData in sampleDatas) _addToLuceneIndex(sampleData, writer);
         analyzer.Close();
     }
 }
开发者ID:Workker,项目名称:EHRLucene,代码行数:9,代码来源:LuceneClient.cs

示例9: AddToIndex

 public void AddToIndex(IEnumerable<Project> projects)
 {
     var analyzer = new StandardAnalyzer(Version.LUCENE_30);
     using (var writer = new IndexWriter(Directory, analyzer, IndexWriter.MaxFieldLength.UNLIMITED))
     {
         foreach (var group in projects)
             AddToIndex(group, writer);
         analyzer.Close();
     }
 }
开发者ID:MikhailGogolushko,项目名称:lmsystem,代码行数:10,代码来源:ProjectSearchMethod.cs

示例10: DeleteIndex

 public void DeleteIndex(int id)
 {
     var analyzer = new StandardAnalyzer(Version.LUCENE_30);
     using (var writer = new IndexWriter(Directory, analyzer, IndexWriter.MaxFieldLength.UNLIMITED))
     {
         var searchQuery = new TermQuery(new Term(SearchingFields.Id.ToString(), id.ToString()));
         writer.DeleteDocuments(searchQuery);
         analyzer.Close();
     }
 }
开发者ID:MikhailGogolushko,项目名称:lmsystem,代码行数:10,代码来源:BaseSearchMethod.cs

示例11: AddToIndex

 public void AddToIndex(IEnumerable<Student> students)
 {
     var analyzer = new StandardAnalyzer(Version.LUCENE_30);
     using (var writer = new IndexWriter(Directory, analyzer, IndexWriter.MaxFieldLength.UNLIMITED))
     {
         foreach (var student in students)
             AddToIndex(student, writer);
         analyzer.Close();
     }
 }
开发者ID:MikhailGogolushko,项目名称:lmsystem,代码行数:10,代码来源:StudentSearchMethod.cs

示例12: ClearIndexRecord

 public static void ClearIndexRecord(int id)
 {
     var analyzer = new StandardAnalyzer(Version.LUCENE_29);
     using (var writer = new IndexWriter(Directory, analyzer, IndexWriter.MaxFieldLength.UNLIMITED))
     {
         var searchQuery = new TermQuery(new Term("Id", Convert.ToString(id)));
         writer.DeleteDocuments(searchQuery);
         analyzer.Close();
     }
 }
开发者ID:Lumenela,项目名称:WebPresentations,代码行数:10,代码来源:LuceneIndexer.cs

示例13: Optimize

        /// <summary>
        /// Optimizes the Lucene index.
        /// </summary>
        /// <param name="luceneVersion">The lucene version.</param>
        /// <param name="fsDirectory">The fs directory.</param>
        /// <param name="maxFieldLength">Maximum length of the field.</param>
		public virtual void Optimize(Version luceneVersion, FSDirectory fsDirectory, IndexWriter.MaxFieldLength maxFieldLength)
		{
			var analyzer = new StandardAnalyzer(luceneVersion);

			using (var indexWriter = new IndexWriter(fsDirectory, analyzer, maxFieldLength))
			{
				analyzer.Close();

				indexWriter.Optimize();
			}
		}
开发者ID:KaraokeStu,项目名称:LeadPipe.Net,代码行数:17,代码来源:SearchIndexOptimizer.cs

示例14: AddDocument

 public static void AddDocument(Document document)
 {
     var analyzer = new StandardAnalyzer(Version.LUCENE_29);
     using (var writer = new IndexWriter(Directory, analyzer, IndexWriter.MaxFieldLength.UNLIMITED))
     {
         writer.AddDocument(document);
         writer.Optimize();
         writer.Commit();
         analyzer.Close();
     }
 }
开发者ID:Lumenela,项目名称:WebPresentations,代码行数:11,代码来源:LuceneIndexer.cs

示例15: ClearIndex

        /// <summary>
        /// Clears the entire index.
        /// </summary>
        /// <param name="luceneVersion">The lucene version.</param>
        /// <param name="fsDirectory">The fs directory.</param>
        /// <param name="maxFieldLength">Maximum length of the field.</param>
		public virtual void ClearIndex(Version luceneVersion, FSDirectory fsDirectory, IndexWriter.MaxFieldLength maxFieldLength)
		{
			var analyzer = new StandardAnalyzer(luceneVersion);

			using (var indexWriter = new IndexWriter(fsDirectory, analyzer, maxFieldLength))
			{
				indexWriter.DeleteAll();

				analyzer.Close();
			}
		}
开发者ID:KaraokeStu,项目名称:LeadPipe.Net,代码行数:17,代码来源:SearchIndexClearer.cs


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