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

C# Search.Query类代码示例

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

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



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

示例1: CustomScoreQuery

		/// <summary> Create a CustomScoreQuery over input subQuery and a {@link ValueSourceQuery}.</summary>
		/// <param name="subQuery">the sub query whose score is being customized. Must not be null.
		/// </param>
		/// <param name="valSrcQueries">value source queries whose scores are used in the custom score
		/// computation. For most simple/convenient use case these would be 
		/// {@link Lucene.Net.Search.Function.FieldScoreQuery FieldScoreQueries}.
		/// This parameter is optional - it can be null or even an empty array.
		/// </param>
		public CustomScoreQuery(Query subQuery, ValueSourceQuery[] valSrcQueries)
		{
			this.subQuery = subQuery;
			this.valSrcQueries = valSrcQueries != null?valSrcQueries:new ValueSourceQuery[0];
			if (subQuery == null)
				throw new System.ArgumentException("<subquery> must not be null!");
		}
开发者ID:VirtueMe,项目名称:ravendb,代码行数:15,代码来源:CustomScoreQuery.cs


示例2: DrillSidewaysQuery

 internal DrillSidewaysQuery(Query baseQuery, Collector drillDownCollector,
     Collector[] drillSidewaysCollectors, Query[] drillDownQueries, bool scoreSubDocsAtOnce)
 {
     this.baseQuery = baseQuery;
     this.drillDownCollector = drillDownCollector;
     this.drillSidewaysCollectors = drillSidewaysCollectors;
     this.drillDownQueries = drillDownQueries;
     this.scoreSubDocsAtOnce = scoreSubDocsAtOnce;
 }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:9,代码来源:DrillSidewaysQuery.cs


示例3: GetIdfWeightedTerms

		/// <summary> Extracts all terms texts of a given Query into an array of WeightedTerms
		/// 
		/// </summary>
		/// <param name="query">     Query to extract term texts from
		/// </param>
		/// <param name="reader">used to compute IDF which can be used to a) score selected fragments better 
		/// b) use graded highlights eg chaning intensity of font color
		/// </param>
		/// <param name="fieldName">the field on which Inverse Document Frequency (IDF) calculations are based
		/// </param>
		/// <returns> an array of the terms used in a query, plus their weights.
		/// </returns>
		public static WeightedTerm[] GetIdfWeightedTerms(Query query, IndexReader reader, System.String fieldName)
		{
			WeightedTerm[] terms = GetTerms(query, false, fieldName);
			int totalNumDocs = reader.NumDocs();
			for (int i = 0; i < terms.Length; i++)
			{
				try
				{
					int docFreq = reader.DocFreq(new Term(fieldName, terms[i].term));
					//IDF algorithm taken from DefaultSimilarity class
					float idf = (float) (System.Math.Log((float) totalNumDocs / (double) (docFreq + 1)) + 1.0);
					terms[i].weight *= idf;
				}
				catch (System.IO.IOException e)
				{
					//ignore 
				}
			}
			return terms;
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:32,代码来源:QueryTermExtractor.cs


示例4: VerifyResults

		// verify results are as expected.
		private void  VerifyResults(float boost, IndexSearcher s, System.Collections.Hashtable h1, System.Collections.Hashtable h2customNeutral, System.Collections.Hashtable h3CustomMul, System.Collections.Hashtable h4CustomAdd, System.Collections.Hashtable h5CustomMulAdd, Query q1, Query q2, Query q3, Query q4, Query q5)
		{
			
			// verify numbers of matches
			Log("#hits = " + h1.Count);
			Assert.AreEqual(h1.Count, h2customNeutral.Count, "queries should have same #hits");
			Assert.AreEqual(h1.Count, h3CustomMul.Count, "queries should have same #hits");
			Assert.AreEqual(h1.Count, h4CustomAdd.Count, "queries should have same #hits");
			Assert.AreEqual(h1.Count, h5CustomMulAdd.Count, "queries should have same #hits");
			
			// verify scores ratios
			for (System.Collections.IEnumerator it = h1.Keys.GetEnumerator(); it.MoveNext(); )
			{
				System.Int32 x = (System.Int32) it.Current;
				
				int doc = x;
				Log("doc = " + doc);
				
				float fieldScore = ExpectedFieldScore(s.GetIndexReader().Document(doc).Get(ID_FIELD));
				Log("fieldScore = " + fieldScore);
				Assert.IsTrue(fieldScore > 0, "fieldScore should not be 0");
				
				float score1 = (float) ((System.Single) h1[x]);
				LogResult("score1=", s, q1, doc, score1);
				
				float score2 = (float) ((System.Single) h2customNeutral[x]);
				LogResult("score2=", s, q2, doc, score2);
				Assert.AreEqual(boost * score1, score2, TEST_SCORE_TOLERANCE_DELTA, "same score (just boosted) for neutral");
				
				float score3 = (float) ((System.Single) h3CustomMul[x]);
				LogResult("score3=", s, q3, doc, score3);
				Assert.AreEqual(boost * fieldScore * score1, score3, TEST_SCORE_TOLERANCE_DELTA, "new score for custom mul");
				
				float score4 = (float) ((System.Single) h4CustomAdd[x]);
				LogResult("score4=", s, q4, doc, score4);
				Assert.AreEqual(boost * (fieldScore + score1), score4, TEST_SCORE_TOLERANCE_DELTA, "new score for custom add");
				
				float score5 = (float) ((System.Single) h5CustomMulAdd[x]);
				LogResult("score5=", s, q5, doc, score5);
				Assert.AreEqual(boost * fieldScore * (score1 + fieldScore), score5, TEST_SCORE_TOLERANCE_DELTA, "new score for custom mul add");
			}
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:43,代码来源:TestCustomScoreQuery.cs


示例5: TestGetRangeFragments

        public virtual void  TestGetRangeFragments()
		{
			System.String queryString = FIELD_NAME + ":[kannedy TO kznnedy]";
			
			//Need to explicitly set the QueryParser property to use RangeQuery rather than RangeFilters
			QueryParser parser = new QueryParser(FIELD_NAME, new StandardAnalyzer());
			parser.SetUseOldRangeQuery(true);
			query = parser.Parse(queryString);
			DoSearching(query);
			
			DoStandardHighlights();
			Assert.IsTrue(numHighlights == 5, "Failed to find correct number of highlights " + numHighlights + " found");
		}
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:13,代码来源:HighlighterTest.cs


示例6: DumbQueryWrapper

			public DumbQueryWrapper(Query q):base()
			{
				this.q = q;
			}
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:4,代码来源:TestMultiAnalyzer.cs


示例7: AddClause

		protected internal virtual void  AddClause(System.Collections.ArrayList clauses, int conj, int mods, Query q)
		{
			AddClause((System.Collections.IList) clauses, conj, mods, q);
		}
开发者ID:VirtueMe,项目名称:ravendb,代码行数:4,代码来源:QueryParser.cs


示例8: NewBooleanClause

		/// <summary> Builds a new BooleanClause instance</summary>
		/// <param name="q">sub query
		/// </param>
		/// <param name="occur">how this clause should occur when matching documents
		/// </param>
		/// <returns> new BooleanClause instance
		/// </returns>
		protected internal virtual BooleanClause NewBooleanClause(Query q, BooleanClause.Occur occur)
		{
			return new BooleanClause(q, occur);
		}
开发者ID:VirtueMe,项目名称:ravendb,代码行数:11,代码来源:QueryParser.cs


示例9: QueryScorer

		/// <summary> </summary>
		/// <param name="query">a Lucene query (ideally rewritten using query.rewrite 
		/// before being passed to this class and the searcher)
		/// </param>
		/// <param name="fieldName">the Field name which is used to match Query terms
		/// </param>
		public QueryScorer(Query query, System.String fieldName):this(QueryTermExtractor.GetTerms(query, false, fieldName))
		{
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:9,代码来源:QueryScorer.cs


示例10: DoSearching

		public virtual void  DoSearching(System.String queryString)
		{
			QueryParser parser = new QueryParser(FIELD_NAME, new StandardAnalyzer());
            parser.SetMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
			query = parser.Parse(queryString);
			DoSearching(query);
		}
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:7,代码来源:HighlighterTest.cs


示例11: QueryTest

		private void  QueryTest(Query query)
		{
			ScoreDoc[] parallelHits = parallel.Search(query, null, 1000).scoreDocs;
			ScoreDoc[] singleHits = single.Search(query, null, 1000).scoreDocs;
			Assert.AreEqual(parallelHits.Length, singleHits.Length);
			for (int i = 0; i < parallelHits.Length; i++)
			{
				Assert.AreEqual(parallelHits[i].score, singleHits[i].score, 0.001f);
				Document docParallel = parallel.Doc(parallelHits[i].doc);
				Document docSingle = single.Doc(singleHits[i].doc);
				Assert.AreEqual(docParallel.Get("f1"), docSingle.Get("f1"));
				Assert.AreEqual(docParallel.Get("f2"), docSingle.Get("f2"));
				Assert.AreEqual(docParallel.Get("f3"), docSingle.Get("f3"));
				Assert.AreEqual(docParallel.Get("f4"), docSingle.Get("f4"));
			}
		}
开发者ID:VirtueMe,项目名称:ravendb,代码行数:16,代码来源:TestParallelReader.cs


示例12: DeleteDocuments

		/// <summary> Deletes the document(s) matching any of the provided queries.
		/// All deletes are flushed at the same time.
		/// 
		/// <p/><b>NOTE</b>: if this method hits an OutOfMemoryError
		/// you should immediately close the writer.  See <a
		/// href="#OOME">above</a> for details.<p/>
		/// 
		/// </summary>
		/// <param name="queries">array of queries to identify the documents
		/// to be deleted
		/// </param>
		/// <throws>  CorruptIndexException if the index is corrupt </throws>
		/// <throws>  IOException if there is a low-level IO error </throws>
		public virtual void  DeleteDocuments(Query[] queries)
		{
			EnsureOpen();
			bool doFlush = docWriter.BufferDeleteQueries(queries);
			if (doFlush)
				Flush(true, false, false);
		}
开发者ID:Mpdreamz,项目名称:lucene.net,代码行数:20,代码来源:IndexWriter.cs


示例13: AddDeleteQuery

 private void AddDeleteQuery(Query query, int docID)
 {
     lock (this) { deletesInRAM.queries[query] = flushedDocCount + docID; }
 }
开发者ID:cqm0609,项目名称:lucene-file-finder,代码行数:4,代码来源:DocumentsWriter.cs


示例14: LogResult

		private void  LogResult(System.String msg, IndexSearcher s, Query q, int doc, float score1)
		{
			QueryUtils.Check(q, s);
			Log(msg + " " + score1);
			Log("Explain by: " + q);
			Log(s.Explain(q, doc));
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:7,代码来源:TestCustomScoreQuery.cs


示例15: TestMultiSearcher

		public virtual void  TestMultiSearcher()
		{
			//setup index 1
			RAMDirectory ramDir1 = new RAMDirectory();
			IndexWriter writer1 = new IndexWriter(ramDir1, new StandardAnalyzer(), true);
			Document d = new Document();
			Field f = new Field(FIELD_NAME, "multiOne", Field.Store.YES, Field.Index.TOKENIZED);
			d.Add(f);
			writer1.AddDocument(d);
			writer1.Optimize();
			writer1.Close();
			IndexReader reader1 = IndexReader.Open(ramDir1);
			
			//setup index 2
			RAMDirectory ramDir2 = new RAMDirectory();
			IndexWriter writer2 = new IndexWriter(ramDir2, new StandardAnalyzer(), true);
			d = new Document();
			f = new Field(FIELD_NAME, "multiTwo", Field.Store.YES, Field.Index.TOKENIZED);
			d.Add(f);
			writer2.AddDocument(d);
			writer2.Optimize();
			writer2.Close();
			IndexReader reader2 = IndexReader.Open(ramDir2);
			
			
			
			IndexSearcher[] searchers = new IndexSearcher[2];
			searchers[0] = new IndexSearcher(ramDir1);
			searchers[1] = new IndexSearcher(ramDir2);
			MultiSearcher multiSearcher = new MultiSearcher(searchers);
			QueryParser parser = new QueryParser(FIELD_NAME, new StandardAnalyzer());
            parser.SetMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
			query = parser.Parse("multi*");
			System.Console.Out.WriteLine("Searching for: " + query.ToString(FIELD_NAME));
			//at this point the multisearcher calls combine(query[])
			hits = multiSearcher.Search(query);
			
			//query = QueryParser.parse("multi*", FIELD_NAME, new StandardAnalyzer());
			Query[] expandedQueries = new Query[2];
			expandedQueries[0] = query.Rewrite(reader1);
			expandedQueries[1] = query.Rewrite(reader2);
			query = query.Combine(expandedQueries);
			
			
			//create an instance of the highlighter with the tags used to surround highlighted text
			Highlighter highlighter = new Highlighter(this, new QueryScorer(query));
			
			for (int i = 0; i < hits.Length(); i++)
			{
				System.String text = hits.Doc(i).Get(FIELD_NAME);
				TokenStream tokenStream = analyzer.TokenStream(FIELD_NAME, new System.IO.StringReader(text));
				System.String highlightedText = highlighter.GetBestFragment(tokenStream, text);
				System.Console.Out.WriteLine(highlightedText);
			}
			Assert.IsTrue(numHighlights == 2, "Failed to find correct number of highlights " + numHighlights + " found");
		}
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:56,代码来源:HighlighterTest.cs


示例16: TestOverlapAnalyzer2

		public virtual void  TestOverlapAnalyzer2()
		{
			
			System.String s = "Hi-Speed10 foo";
			
			Query query; Highlighter highlighter; System.String result;
			
			query = new QueryParser("text", new WhitespaceAnalyzer()).Parse("foo");
			highlighter = new Highlighter(new QueryScorer(query));
			result = highlighter.GetBestFragments(GetTS2(), s, 3, "...");
			Assert.AreEqual(result, "Hi-Speed10 <B>foo</B>");
			
			query = new QueryParser("text", new WhitespaceAnalyzer()).Parse("10");
			highlighter = new Highlighter(new QueryScorer(query));
			result = highlighter.GetBestFragments(GetTS2(), s, 3, "...");
			Assert.AreEqual(result, "Hi-Speed<B>10</B> foo");
			
			query = new QueryParser("text", new WhitespaceAnalyzer()).Parse("hi");
			highlighter = new Highlighter(new QueryScorer(query));
			result = highlighter.GetBestFragments(GetTS2(), s, 3, "...");
			Assert.AreEqual(result, "<B>Hi</B>-Speed10 foo");
			
			query = new QueryParser("text", new WhitespaceAnalyzer()).Parse("speed");
			highlighter = new Highlighter(new QueryScorer(query));
			result = highlighter.GetBestFragments(GetTS2(), s, 3, "...");
			Assert.AreEqual(result, "Hi-<B>Speed</B>10 foo");
			
			query = new QueryParser("text", new WhitespaceAnalyzer()).Parse("hispeed");
			highlighter = new Highlighter(new QueryScorer(query));
			result = highlighter.GetBestFragments(GetTS2(), s, 3, "...");
			Assert.AreEqual(result, "<B>Hi-Speed</B>10 foo");
			
			query = new QueryParser("text", new WhitespaceAnalyzer()).Parse("hi speed");
			highlighter = new Highlighter(new QueryScorer(query));
			result = highlighter.GetBestFragments(GetTS2(), s, 3, "...");
			Assert.AreEqual(result, "<B>Hi-Speed</B>10 foo");
			
			/////////////////// same tests, just put the bigger overlapping token first
			query = new QueryParser("text", new WhitespaceAnalyzer()).Parse("foo");
			highlighter = new Highlighter(new QueryScorer(query));
			result = highlighter.GetBestFragments(GetTS2a(), s, 3, "...");
			Assert.AreEqual(result, "Hi-Speed10 <B>foo</B>");
			
			query = new QueryParser("text", new WhitespaceAnalyzer()).Parse("10");
			highlighter = new Highlighter(new QueryScorer(query));
			result = highlighter.GetBestFragments(GetTS2a(), s, 3, "...");
			Assert.AreEqual(result, "Hi-Speed<B>10</B> foo");
			
			query = new QueryParser("text", new WhitespaceAnalyzer()).Parse("hi");
			highlighter = new Highlighter(new QueryScorer(query));
			result = highlighter.GetBestFragments(GetTS2a(), s, 3, "...");
			Assert.AreEqual(result, "<B>Hi</B>-Speed10 foo");
			
			query = new QueryParser("text", new WhitespaceAnalyzer()).Parse("speed");
			highlighter = new Highlighter(new QueryScorer(query));
			result = highlighter.GetBestFragments(GetTS2a(), s, 3, "...");
			Assert.AreEqual(result, "Hi-<B>Speed</B>10 foo");
			
			query = new QueryParser("text", new WhitespaceAnalyzer()).Parse("hispeed");
			highlighter = new Highlighter(new QueryScorer(query));
			result = highlighter.GetBestFragments(GetTS2a(), s, 3, "...");
			Assert.AreEqual(result, "<B>Hi-Speed</B>10 foo");
			
			query = new QueryParser("text", new WhitespaceAnalyzer()).Parse("hi speed");
			highlighter = new Highlighter(new QueryScorer(query));
			result = highlighter.GetBestFragments(GetTS2a(), s, 3, "...");
			Assert.AreEqual(result, "<B>Hi-Speed</B>10 foo");
		}
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:68,代码来源:HighlighterTest.cs


示例17: BufferDeleteQueries

		internal bool BufferDeleteQueries(Query[] queries)
		{
			lock (this)
			{
				WaitReady(null);
				for (int i = 0; i < queries.Length; i++)
					AddDeleteQuery(queries[i], numDocsInRAM);
				return TimeToFlushDeletes();
			}
		}
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:10,代码来源:DocumentsWriter.cs


示例18: BufferDeleteQuery

		internal bool BufferDeleteQuery(Query query)
		{
			lock (this)
			{
				WaitReady(null);
				AddDeleteQuery(query, numDocsInRAM);
				return TimeToFlushDeletes();
			}
		}
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:9,代码来源:DocumentsWriter.cs


示例19: AddDeleteQuery

		private void  AddDeleteQuery(Query query, int docID)
		{
			lock (this)
			{
				deletesInRAM.queries[query] = (System.Int32) (flushedDocCount + docID);
				deletesInRAM.AddBytesUsed(BYTES_PER_DEL_QUERY);
			}
		}
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:8,代码来源:DocumentsWriter.cs


示例20: CheckHits

		private void  CheckHits(Query query, int[] results)
		{
            Lucene.Net.Search.CheckHits.CheckHits_Renamed_Method(query, field, searcher, results);
		}
开发者ID:Rationalle,项目名称:ravendb,代码行数:4,代码来源:TestSpans.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Search.Similarity类代码示例发布时间:2022-05-24
下一篇:
C# Search.IndexSearcher类代码示例发布时间: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