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


C# Search.Searcher类代码示例

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


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

示例1: SearchResults

        internal SearchResults(Query query, IEnumerable<SortField> sortField, Searcher searcher, int maxResults)
        {
            LuceneQuery = query;

            LuceneSearcher = searcher;
            DoSearch(query, sortField, maxResults);
        }
开发者ID:rhayesbite,项目名称:Examine,代码行数:7,代码来源:SearchResults.cs

示例2: CheckHits_

		public static void  CheckHits_(Query query, System.String defaultFieldName, Searcher searcher, int[] results, TestCase testCase)
		{
            Hits hits = searcher.Search(query);
			
            System.Collections.Hashtable correct = new System.Collections.Hashtable();
            for (int i = 0; i < results.Length; i++)
            {
                correct.Add((System.Int32) results[i], null);
            }
			
            System.Collections.Hashtable actual = new System.Collections.Hashtable();
            for (int i = 0; i < hits.Length(); i++)
            {
                actual.Add((System.Int32) hits.Id(i), null);
            }
			
            //Assert.AreEqual(correct, actual, query.ToString(defaultFieldName));
            if (correct.Count != 0)
            {
                System.Collections.IDictionaryEnumerator iter = correct.GetEnumerator();
                bool status = false;
                while (iter.MoveNext())
                {
                    status = actual.ContainsKey(iter.Key);
                    if (status == false)
                        break;
                }
                Assert.IsTrue(status, query.ToString(defaultFieldName));
            }
        }
开发者ID:emtees,项目名称:old-code,代码行数:30,代码来源:CheckHits.cs

示例3: Search

        public List<HintResult> Search(Predicate query, int count)
        {
            if (_searcher == null)
            {
                _searcher = new IndexSearcher(this._directory, true);
            }

            TopDocs docsFound = _searcher.Search(query.GetQuery(), count);

            var list = new List<HintResult>();

            foreach (var score in docsFound.ScoreDocs)
            {
                Document doc = this._searcher.Doc(score.doc);

                var result = new HintResult();

                foreach (var field in doc.GetFields())
                {
                    //result.FieldsValues.Add(field. .Name(), field.StringValue());
                }

                list.Add(result);
            }

            return list;
        }
开发者ID:bemidio,项目名称:CSharpProjects,代码行数:27,代码来源:LuceneBag.cs

示例4: TermWeight

			public TermWeight(TermQuery enclosingInstance, Searcher searcher)
			{
				InitBlock(enclosingInstance);
				this.similarity = Enclosing_Instance.GetSimilarity(searcher);
				idfExp = similarity.IdfExplain(Enclosing_Instance.term, searcher);
				idf = idfExp.Idf;
			}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:7,代码来源:TermQuery.cs

示例5: LuceneSearchResults

 /// <summary>
 ///     Initializes a new instance of the <see cref="SearchResults" /> class.
 /// </summary>
 /// <param name="searcher">The searcher.</param>
 /// <param name="reader">The reader.</param>
 /// <param name="docs">The hits.</param>
 /// <param name="criteria">The criteria.</param>
 /// <param name="query">The query.</param>
 public LuceneSearchResults(Searcher searcher, IndexReader reader, TopDocs docs, ISearchCriteria criteria, Query query)
 {
     Results = new SearchResults(criteria, null);
     CreateDocuments(searcher, docs);
     CreateFacets(reader, query);
     CreateSuggestions(reader, criteria);
 }
开发者ID:sameerkattel,项目名称:vc-community,代码行数:15,代码来源:LuceneSearchResults.cs

示例6: Hits

 internal Hits(Searcher s, Query q, Filter f)
 {
     weight = q.Weight(s);
     searcher = s;
     filter = f;
     GetMoreDocs(50); // retrieve 100 initially
 }
开发者ID:vineelkovvuri,项目名称:ExtendableDesktopSearch,代码行数:7,代码来源:Hits.cs

示例7: CountDeletions

		// count # deletions, return -1 if unknown.
		private int CountDeletions(Searcher s)
		{
			int cnt = - 1;
			if (s is IndexSearcher)
			{
				cnt = s.MaxDoc() - ((IndexSearcher) s).GetIndexReader().NumDocs();
			}
			return cnt;
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:10,代码来源:Hits.cs

示例8: SpanWeight

		public SpanWeight(SpanQuery query, Searcher searcher)
		{
			this.similarity = query.GetSimilarity(searcher);
			this.query = query;
            terms = new Support.Set<Lucene.Net.Index.Term>();
			query.ExtractTerms(terms);
			idfExp = similarity.idfExplain(terms.ToArray(), searcher);
			idf = idfExp.GetIdf();
		}
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:9,代码来源:SpanWeight.cs

示例9: SpanWeight

		public SpanWeight(SpanQuery query, Searcher searcher)
		{
			this.similarity = query.GetSimilarity(searcher);
			this.query = query;
			terms = new System.Collections.Hashtable();
			query.ExtractTerms(terms);
			idfExp = similarity.idfExplain(new System.Collections.ArrayList(terms.Values), searcher);
			idf = idfExp.GetIdf();
		}
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:9,代码来源:SpanWeight.cs

示例10: Hits

		public /*internal*/ bool debugCheckedForDeletions = false; // for test purposes.
		
		internal Hits(Searcher s, Query q, Filter f)
		{
			weight = q.Weight(s);
			searcher = s;
			filter = f;
			nDeletions = CountDeletions(s);
			GetMoreDocs(50); // retrieve 100 initially
			lengthAtStart = length;
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:11,代码来源:Hits.cs

示例11: SpanWeight

        public SpanWeight(SpanQuery query, Searcher searcher)
        {
            this.similarity = query.GetSimilarity(searcher);
            this.query = query;
            terms = new System.Collections.Hashtable();
            query.ExtractTerms(terms);

            System.Collections.ArrayList tmp = new System.Collections.ArrayList(terms.Values);

            idf = this.query.GetSimilarity(searcher).Idf(tmp, searcher);
        }
开发者ID:cqm0609,项目名称:lucene-file-finder,代码行数:11,代码来源:SpanWeight.cs

示例12: GetHighlight

		public string GetHighlight(string value, string highlightField, Searcher searcher, string luceneRawQuery)
		{
			var query = GetQueryParser(highlightField).Parse(luceneRawQuery);
			var scorer = new QueryScorer(searcher.Rewrite(query));

			var highlighter = new Highlighter(HighlightFormatter, scorer);

			var tokenStream = HighlightAnalyzer.TokenStream(highlightField, new StringReader(value));
			string bestFragments = highlighter.GetBestFragments(tokenStream, value, MaxNumHighlights, Separator);
			return bestFragments;
		}
开发者ID:joosthollander,项目名称:Macaw.Umbraco.Foundation,代码行数:11,代码来源:LuceneHighlightHelper.cs

示例13: SpanWeight

        public SpanWeight(SpanQuery query, Searcher searcher)
        {
            this.similarity = query.GetSimilarity(searcher);
            this.internalQuery = query;

            terms = Lucene.Net.Support.Compatibility.SetFactory.CreateHashSet<Term>();
            query.ExtractTerms(terms);

            idfExp = similarity.IdfExplain(terms, searcher);
            idf = idfExp.Idf;
        }
开发者ID:Nangal,项目名称:lucene.net,代码行数:11,代码来源:SpanWeight.cs

示例14: GetResults

        private static void GetResults(ref List<Airport> itemsList, TopDocs results, Searcher searcher)
        {
            foreach (ScoreDoc scoreDoc in results.ScoreDocs)
            {
                var item = new Airport();
                Document doc = searcher.Doc(scoreDoc.Doc);
                item.id = doc.Get("Code");
                item.label = doc.Get("CityName") + " - " + doc.Get("Name") + " (" +
                             doc.Get("Code") + ")";
                item.value = doc.Get("CityName") + " - " + doc.Get("Name") + " (" +
                             doc.Get("Code") + ")";

                itemsList.Add(item);
            }
        }
开发者ID:varunupcurve,项目名称:myrepo,代码行数:15,代码来源:DestinationService.cs

示例15: CreateDocuments

        /// <summary>
        /// Creates result document collection from Lucene documents.
        /// </summary>
        /// <param name="searcher">The searcher.</param>
        /// <param name="topDocs">The hits.</param>
        private void CreateDocuments(Searcher searcher, TopDocs topDocs)
        {
            // if no documents found return
            if (topDocs == null)
                return;

            var entries = new List<ResultDocument>();

            // get total hits
            var totalCount = topDocs.TotalHits;
            var recordsToRetrieve = Results.SearchCriteria.RecordsToRetrieve;
            var startIndex = Results.SearchCriteria.StartingRecord;
            if (recordsToRetrieve > totalCount)
                recordsToRetrieve = totalCount;

            for (var index = startIndex; index < startIndex + recordsToRetrieve; index++)
            {
                if (index >= totalCount)
                    break;

                var document = searcher.Doc(topDocs.ScoreDocs[index].Doc);
                var doc = new ResultDocument();

                var documentFields = document.GetFields();
                using (var fi = documentFields.GetEnumerator())
                {
                    while (fi.MoveNext())
                    {
                        if (fi.Current != null)
                        {
                            var field = fi.Current;
                            doc.Add(new DocumentField(field.Name, field.StringValue));
                        }
                    }
                }

                entries.Add(doc);
            }

            var searchDocuments = new ResultDocumentSet
            {
                Name = "Items",
                Documents = entries.OfType<IDocument>().ToArray(),
                TotalCount = totalCount
            };

            Results.Documents = new[] { searchDocuments };
        }
开发者ID:sameerkattel,项目名称:vc-community,代码行数:53,代码来源:LuceneSearchResults.cs


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