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


C# SpanTermQuery.GetSpans方法代码示例

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


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

示例1: TestSpanTermQuery

		public virtual void  TestSpanTermQuery()
		{
			SpanTermQuery stq;
			Spans spans;
			stq = new SpanTermQuery(new Term(PayloadHelper.FIELD, "seventy"));
			spans = stq.GetSpans(indexReader);
			Assert.IsTrue(spans != null, "spans is null and it shouldn't be");
			CheckSpans(spans, 100, 1, 1, 1);
			
			stq = new SpanTermQuery(new Term(PayloadHelper.NO_PAYLOAD_FIELD, "seventy"));
			spans = stq.GetSpans(indexReader);
			Assert.IsTrue(spans != null, "spans is null and it shouldn't be");
			CheckSpans(spans, 100, 0, 0, 0);
		}
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:14,代码来源:TestPayloadSpans.cs

示例2: TestNestedSpans

		public virtual void  TestNestedSpans()
		{
			SpanTermQuery stq;
			Spans spans;
			IndexSearcher searcher = GetSearcher();
			stq = new SpanTermQuery(new Term(PayloadHelper.FIELD, "mark"));
			spans = stq.GetSpans(searcher.GetIndexReader());
			Assert.IsTrue(spans != null, "spans is null and it shouldn't be");
			CheckSpans(spans, 0, null);
			
			
			SpanQuery[] clauses = new SpanQuery[3];
			clauses[0] = new SpanTermQuery(new Term(PayloadHelper.FIELD, "rr"));
			clauses[1] = new SpanTermQuery(new Term(PayloadHelper.FIELD, "yy"));
			clauses[2] = new SpanTermQuery(new Term(PayloadHelper.FIELD, "xx"));
			SpanNearQuery spanNearQuery = new SpanNearQuery(clauses, 12, false);
			
			spans = spanNearQuery.GetSpans(searcher.GetIndexReader());
			Assert.IsTrue(spans != null, "spans is null and it shouldn't be");
			CheckSpans(spans, 2, new int[]{3, 3});
			
			
			clauses[0] = new SpanTermQuery(new Term(PayloadHelper.FIELD, "xx"));
			clauses[1] = new SpanTermQuery(new Term(PayloadHelper.FIELD, "rr"));
			clauses[2] = new SpanTermQuery(new Term(PayloadHelper.FIELD, "yy"));
			
			spanNearQuery = new SpanNearQuery(clauses, 6, true);
			
			
			spans = spanNearQuery.GetSpans(searcher.GetIndexReader());
			Assert.IsTrue(spans != null, "spans is null and it shouldn't be");
			CheckSpans(spans, 1, new int[]{3});
			
			clauses = new SpanQuery[2];
			
			clauses[0] = new SpanTermQuery(new Term(PayloadHelper.FIELD, "xx"));
			clauses[1] = new SpanTermQuery(new Term(PayloadHelper.FIELD, "rr"));
			
			spanNearQuery = new SpanNearQuery(clauses, 6, true);
			
			// xx within 6 of rr
			
			SpanQuery[] clauses2 = new SpanQuery[2];
			
			clauses2[0] = new SpanTermQuery(new Term(PayloadHelper.FIELD, "yy"));
			clauses2[1] = spanNearQuery;
			
			SpanNearQuery nestedSpanNearQuery = new SpanNearQuery(clauses2, 6, false);
			
			// yy within 6 of xx within 6 of rr
			
			spans = nestedSpanNearQuery.GetSpans(searcher.GetIndexReader());
			Assert.IsTrue(spans != null, "spans is null and it shouldn't be");
			CheckSpans(spans, 2, new int[]{3, 3});
		}
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:55,代码来源:TestPayloadSpans.cs

示例3: TestSpansSkipTo

 public virtual void  TestSpansSkipTo()
 {
     SpanTermQuery t1 = new SpanTermQuery(new Term("field", "seventy"));
     SpanTermQuery t2 = new SpanTermQuery(new Term("field", "seventy"));
     Spans s1 = t1.GetSpans(searcher.IndexReader);
     Spans s2 = t2.GetSpans(searcher.IndexReader);
     
     Assert.IsTrue(s1.Next());
     Assert.IsTrue(s2.Next());
     
     bool hasMore = true;
     
     do 
     {
         hasMore = SkipToAccoringToJavaDocs(s1, s1.Doc());
         Assert.AreEqual(hasMore, s2.SkipTo(s2.Doc()));
         Assert.AreEqual(s1.Doc(), s2.Doc());
     }
     while (hasMore);
 }
开发者ID:Nangal,项目名称:lucene.net,代码行数:20,代码来源:TestBasics.cs


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