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


C# Lucene.Net.Search.IndexSearcher.Explain方法代码示例

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


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

示例1: DoTestRank

 // Test that FieldScoreQuery returns docs in expected order.
 private void  DoTestRank(System.String field, FieldScoreQuery.Type tp)
 {
     IndexSearcher s = new IndexSearcher(dir, true);
     Query q = new FieldScoreQuery(field, tp);
     Log("test: " + q);
     QueryUtils.Check(q, s);
     ScoreDoc[] h = s.Search(q, null, 1000).ScoreDocs;
     Assert.AreEqual(N_DOCS, h.Length, "All docs should be matched!");
     System.String prevID = "ID" + (N_DOCS + 1); // greater than all ids of docs in this test
     for (int i = 0; i < h.Length; i++)
     {
         System.String resID = s.Doc(h[i].Doc).Get(ID_FIELD);
         Log(i + ".   score=" + h[i].Score + "  -  " + resID);
         Log(s.Explain(q, h[i].Doc));
         Assert.IsTrue(String.CompareOrdinal(resID, prevID) < 0, "res id " + resID + " should be < prev res id " + prevID);
         prevID = resID;
     }
 }
开发者ID:Nangal,项目名称:lucene.net,代码行数:19,代码来源:TestFieldScoreQuery.cs

示例2: DoTestExactScore

 // Test that FieldScoreQuery returns docs with expected score.
 private void  DoTestExactScore(System.String field, FieldScoreQuery.Type tp)
 {
     IndexSearcher s = new IndexSearcher(dir, true);
     Query q = new FieldScoreQuery(field, tp);
     TopDocs td = s.Search(q, null, 1000);
     Assert.AreEqual(N_DOCS, td.TotalHits, "All docs should be matched!");
     ScoreDoc[] sd = td.ScoreDocs;
     for (int i = 0; i < sd.Length; i++)
     {
         float score = sd[i].Score;
         Log(s.Explain(q, sd[i].Doc));
         System.String id = s.IndexReader.Document(sd[i].Doc).Get(ID_FIELD);
         float expectedScore = ExpectedFieldScore(id); // "ID7" --> 7.0
         Assert.AreEqual(expectedScore, score, TEST_SCORE_TOLERANCE_DELTA, "score of " + id + " shuould be " + expectedScore + " != " + score);
     }
 }
开发者ID:Nangal,项目名称:lucene.net,代码行数:17,代码来源:TestFieldScoreQuery.cs

示例3: DoTestExactScore

		// Test that queries based on reverse/ordFieldScore returns docs with expected score.
		private void  DoTestExactScore(System.String field, bool inOrder)
		{
			IndexSearcher s = new IndexSearcher(dir, true);
			ValueSource vs;
			if (inOrder)
			{
				vs = new OrdFieldSource(field);
			}
			else
			{
				vs = new ReverseOrdFieldSource(field);
			}
			Query q = new ValueSourceQuery(vs);
			TopDocs td = s.Search(q, null, 1000);
			Assert.AreEqual(N_DOCS, td.TotalHits, "All docs should be matched!");
			ScoreDoc[] sd = td.ScoreDocs;
			for (int i = 0; i < sd.Length; i++)
			{
				float score = sd[i].Score;
				System.String id = s.IndexReader.Document(sd[i].Doc).Get(ID_FIELD);
				Log("-------- " + i + ". Explain doc " + id);
				Log(s.Explain(q, sd[i].Doc));
				float expectedScore = N_DOCS - i;
				Assert.AreEqual(expectedScore, score, TEST_SCORE_TOLERANCE_DELTA, "score of result " + i + " shuould be " + expectedScore + " != " + score);
				System.String expectedId = inOrder?Id2String(N_DOCS - i):Id2String(i + 1); // reverse  ==> smaller values first 
				Assert.IsTrue(expectedId.Equals(id), "id of result " + i + " shuould be " + expectedId + " != " + score);
			}
		}
开发者ID:synhershko,项目名称:lucene.net,代码行数:29,代码来源:TestOrdValues.cs

示例4: DoTestRank

		// Test that queries based on reverse/ordFieldScore scores correctly
		private void  DoTestRank(System.String field, bool inOrder)
		{
			IndexSearcher s = new IndexSearcher(dir, true);
			ValueSource vs;
			if (inOrder)
			{
				vs = new OrdFieldSource(field);
			}
			else
			{
				vs = new ReverseOrdFieldSource(field);
			}
			
			Query q = new ValueSourceQuery(vs);
			Log("test: " + q);
			QueryUtils.Check(q, s);
			ScoreDoc[] h = s.Search(q, null, 1000).ScoreDocs;
			Assert.AreEqual(N_DOCS, h.Length, "All docs should be matched!");
			System.String prevID = inOrder?"IE":"IC"; // smaller than all ids of docs in this test ("ID0001", etc.)
			
			for (int i = 0; i < h.Length; i++)
			{
				System.String resID = s.Doc(h[i].Doc).Get(ID_FIELD);
				Log(i + ".   score=" + h[i].Score + "  -  " + resID);
				Log(s.Explain(q, h[i].Doc));
				if (inOrder)
				{
					Assert.IsTrue(String.CompareOrdinal(resID, prevID) < 0, "res id " + resID + " should be < prev res id " + prevID);
				}
				else
				{
					Assert.IsTrue(String.CompareOrdinal(resID, prevID) > 0, "res id " + resID + " should be > prev res id " + prevID);
				}
				prevID = resID;
			}
		}
开发者ID:synhershko,项目名称:lucene.net,代码行数:37,代码来源:TestOrdValues.cs

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


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