本文整理汇总了C#中Lucene.Net.Search.Spans.SpanOrQuery.GetSpans方法的典型用法代码示例。如果您正苦于以下问题:C# SpanOrQuery.GetSpans方法的具体用法?C# SpanOrQuery.GetSpans怎么用?C# SpanOrQuery.GetSpans使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Search.Spans.SpanOrQuery
的用法示例。
在下文中一共展示了SpanOrQuery.GetSpans方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestSpans1
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: TestSpans0
public virtual void TestSpans0()
{
SpanQuery q1 = new SpanTermQuery(new Term("gender", "female"));
SpanQuery q2 = new SpanTermQuery(new Term("first", "james"));
SpanQuery q = new SpanOrQuery(new SpanQuery[]{q1, new FieldMaskingSpanQuery(q2, "gender")});
Check(q, new int[]{0, 1, 2, 3, 4});
Spans span = q.GetSpans(searcher.GetIndexReader());
Assert.AreEqual(true, span.Next());
Assert.AreEqual(S(0, 0, 1), S(span));
Assert.AreEqual(true, span.Next());
Assert.AreEqual(S(1, 0, 1), S(span));
Assert.AreEqual(true, span.Next());
Assert.AreEqual(S(1, 1, 2), S(span));
Assert.AreEqual(true, span.Next());
Assert.AreEqual(S(2, 0, 1), S(span));
Assert.AreEqual(true, span.Next());
Assert.AreEqual(S(2, 1, 2), S(span));
Assert.AreEqual(true, span.Next());
Assert.AreEqual(S(2, 2, 3), S(span));
Assert.AreEqual(true, span.Next());
Assert.AreEqual(S(3, 0, 1), S(span));
Assert.AreEqual(true, span.Next());
Assert.AreEqual(S(4, 0, 1), S(span));
Assert.AreEqual(true, span.Next());
Assert.AreEqual(S(4, 1, 2), S(span));
Assert.AreEqual(false, span.Next());
}