GetSpans() public method

public GetSpans ( AtomicReaderContext context, Bits acceptDocs, TermContext>.IDictionary termContexts ) : Lucene.Net.Search.Spans.Spans
context AtomicReaderContext
acceptDocs Bits
termContexts TermContext>.IDictionary
return Lucene.Net.Search.Spans.Spans
Exemplo n.º 1
0
        public virtual void  TestNestedSpans()
        {
            SpanTermQuery stq;
            Spans         spans;
            IndexSearcher searcher = GetSearcher();

            stq   = new SpanTermQuery(new Term(PayloadHelper.FIELD, "mark"));
            spans = stq.GetSpans(searcher.IndexReader);
            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.IndexReader);
            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.IndexReader);
            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.IndexReader);
            Assert.IsTrue(spans != null, "spans is null and it shouldn't be");
            CheckSpans(spans, 2, new int[] { 3, 3 });
        }
		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);
		}
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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, null);
            Spans         s2 = t2.GetSpans(searcher.IndexReader, null);

            Assert.IsTrue(s1.Next(null));
            Assert.IsTrue(s2.Next(null));

            bool hasMore = true;

            do
            {
                hasMore = SkipToAccoringToJavaDocs(s1, s1.Doc());
                Assert.AreEqual(hasMore, s2.SkipTo(s2.Doc(), null));
                Assert.AreEqual(s1.Doc(), s2.Doc());
            }while (hasMore);
        }
		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});
		}
Exemplo n.º 6
0
 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);
 }