GetSpans() public method

public GetSpans ( IndexReader reader ) : Lucene.Net.Search.Spans.Spans
reader Lucene.Net.Index.IndexReader
return Lucene.Net.Search.Spans.Spans
コード例 #1
0
        public virtual void  TestSpans1()
        {
            SpanQuery q1 = new SpanTermQuery(new Term("first", "sally"));
            SpanQuery q2 = new SpanTermQuery(new Term("first", "james"));
            SpanQuery qA = new SpanOrQuery(new SpanQuery[] { q1, q2 });
            SpanQuery qB = new FieldMaskingSpanQuery(qA, "id");

            Check(qA, new int[] { 0, 1, 2, 4 });
            Check(qB, new int[] { 0, 1, 2, 4 });

            Spans spanA = qA.GetSpans(searcher.GetIndexReader());
            Spans spanB = qB.GetSpans(searcher.GetIndexReader());

            while (spanA.Next())
            {
                Assert.IsTrue(spanB.Next(), "spanB not still going");
                Assert.AreEqual(S(spanA), S(spanB), "spanA not equal spanB");
            }
            Assert.IsTrue(!(spanB.Next()), "spanB still going even tough spanA is done");
        }
コード例 #2
0
		public virtual void  TestSpans1()
		{
			SpanQuery q1 = new SpanTermQuery(new Term("first", "sally"));
			SpanQuery q2 = new SpanTermQuery(new Term("first", "james"));
			SpanQuery qA = new SpanOrQuery(new SpanQuery[]{q1, q2});
			SpanQuery qB = new FieldMaskingSpanQuery(qA, "id");
			
			Check(qA, new int[]{0, 1, 2, 4});
			Check(qB, new int[]{0, 1, 2, 4});
			
			Spans spanA = qA.GetSpans(searcher.GetIndexReader());
			Spans spanB = qB.GetSpans(searcher.GetIndexReader());
			
			while (spanA.Next())
			{
				Assert.IsTrue(spanB.Next(), "spanB not still going");
				Assert.AreEqual(S(spanA), S(spanB), "spanA not equal spanB");
			}
			Assert.IsTrue(!(spanB.Next()), "spanB still going even tough spanA is done");
		}