本文整理汇总了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);
}
示例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});
}
示例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);
}