本文整理汇总了C#中Lucene.Net.Search.Spans.SpanOrQuery类的典型用法代码示例。如果您正苦于以下问题:C# SpanOrQuery类的具体用法?C# SpanOrQuery怎么用?C# SpanOrQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SpanOrQuery类属于Lucene.Net.Search.Spans命名空间,在下文中一共展示了SpanOrQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitBlock
private void InitBlock(Lucene.Net.Index.IndexReader reader, SpanOrQuery enclosingInstance)
{
this.reader = reader;
this.enclosingInstance = enclosingInstance;
all = new System.Collections.ArrayList(Enclosing_Instance.clauses.Count);
queue = new SpanQueue(enclosingInstance, Enclosing_Instance.clauses.Count);
System.Collections.IEnumerator i = Enclosing_Instance.clauses.GetEnumerator();
while (i.MoveNext())
{
// initialize all
all.Add(((SpanQuery) i.Current).GetSpans(reader));
}
}
示例2: Clone
public override System.Object Clone()
{
int sz = clauses.Count;
SpanQuery[] newClauses = new SpanQuery[sz];
for (int i = 0; i < sz; i++)
{
SpanQuery clause = (SpanQuery) clauses[i];
newClauses[i] = (SpanQuery) clause.Clone();
}
SpanOrQuery soq = new SpanOrQuery(newClauses);
soq.SetBoost(GetBoost());
return soq;
}
示例3: GetSpanQuery
public override SpanQuery GetSpanQuery(XmlElement e)
{
string fieldName = DOMUtils.GetAttributeWithInheritanceOrFail(e, "fieldName");
string value = DOMUtils.GetNonBlankTextOrFail(e);
List<SpanQuery> clausesList = new List<SpanQuery>();
TokenStream ts = null;
try
{
ts = analyzer.TokenStream(fieldName, value);
ITermToBytesRefAttribute termAtt = ts.AddAttribute<ITermToBytesRefAttribute>();
BytesRef bytes = termAtt.BytesRef;
ts.Reset();
while (ts.IncrementToken())
{
termAtt.FillBytesRef();
SpanTermQuery stq = new SpanTermQuery(new Term(fieldName, BytesRef.DeepCopyOf(bytes)));
clausesList.Add(stq);
}
ts.End();
SpanOrQuery soq = new SpanOrQuery(clausesList.ToArray(/*new SpanQuery[clausesList.size()]*/));
soq.Boost = DOMUtils.GetAttribute(e, "boost", 1.0f);
return soq;
}
#pragma warning disable 168
catch (IOException ioe)
#pragma warning restore 168
{
throw new ParserException("IOException parsing value:" + value);
}
finally
{
IOUtils.CloseWhileHandlingException(ts);
}
}
示例4: VisitQuery
private static void VisitQuery(SpanOrQuery query, AzureQueryLogger.IndentedTextWriter writer)
{
SpanQuery[] clauses = query.GetClauses();
AzureQueryLogger.VisitClauses(writer, clauses);
}
示例5: TestSpanComplex1
public virtual void TestSpanComplex1()
{
SpanTermQuery t1 = new SpanTermQuery(new Term("Field", "six"));
SpanTermQuery t2 = new SpanTermQuery(new Term("Field", "hundred"));
SpanNearQuery tt1 = new SpanNearQuery(new SpanQuery[]{t1, t2}, 0, true);
SpanTermQuery t3 = new SpanTermQuery(new Term("Field", "seven"));
SpanTermQuery t4 = new SpanTermQuery(new Term("Field", "hundred"));
SpanNearQuery tt2 = new SpanNearQuery(new SpanQuery[]{t3, t4}, 0, true);
SpanTermQuery t5 = new SpanTermQuery(new Term("Field", "seven"));
SpanTermQuery t6 = new SpanTermQuery(new Term("Field", "six"));
SpanOrQuery to1 = new SpanOrQuery(new SpanQuery[]{tt1, tt2});
SpanOrQuery to2 = new SpanOrQuery(new SpanQuery[]{t5, t6});
SpanNearQuery query = new SpanNearQuery(new SpanQuery[]{to1, to2}, 100, true);
CheckHits(query, new int[]{606, 607, 626, 627, 636, 637, 646, 647, 656, 657, 666, 667, 676, 677, 686, 687, 696, 697, 706, 707, 726, 727, 736, 737, 746, 747, 756, 757, 766, 767, 776, 777, 786, 787, 796, 797});
}
示例6: TestSpanOr
public virtual void TestSpanOr()
{
SpanTermQuery term1 = new SpanTermQuery(new Term("Field", "thirty"));
SpanTermQuery term2 = new SpanTermQuery(new Term("Field", "three"));
SpanNearQuery near1 = new SpanNearQuery(new SpanQuery[]{term1, term2}, 0, true);
SpanTermQuery term3 = new SpanTermQuery(new Term("Field", "forty"));
SpanTermQuery term4 = new SpanTermQuery(new Term("Field", "seven"));
SpanNearQuery near2 = new SpanNearQuery(new SpanQuery[]{term3, term4}, 0, true);
SpanOrQuery query = new SpanOrQuery(new SpanQuery[]{near1, near2});
CheckHits(query, new int[]{33, 47, 133, 147, 233, 247, 333, 347, 433, 447, 533, 547, 633, 647, 733, 747, 833, 847, 933, 947});
Assert.IsTrue(searcher.Explain(query, 33).GetValue() > 0.0f);
Assert.IsTrue(searcher.Explain(query, 947).GetValue() > 0.0f);
}
示例7: TestSpanOrVersusBoolean
public virtual void TestSpanOrVersusBoolean()
{
Term t1 = RandomTerm();
Term t2 = RandomTerm();
BooleanQuery q1 = new BooleanQuery();
q1.Add(new TermQuery(t1), Occur.SHOULD);
q1.Add(new TermQuery(t2), Occur.SHOULD);
SpanOrQuery q2 = new SpanOrQuery(new SpanTermQuery(t1), new SpanTermQuery(t2));
AssertSameSet(q1, q2);
}
示例8: SpanQueue
public SpanQueue(SpanOrQuery enclosingInstance, int size)
{
InitBlock(enclosingInstance);
Initialize(size);
}
示例9: TestSpanOrEmpty
public virtual void TestSpanOrEmpty()
{
Spans spans = OrSpans(new string[0]);
Assert.IsFalse(spans.Next(), "empty next");
SpanOrQuery a = new SpanOrQuery();
SpanOrQuery b = new SpanOrQuery();
Assert.IsTrue(a.Equals(b), "empty should equal");
}
示例10: TestSpans2
public virtual void TestSpans2()
{
AssumeTrue("Broken scoring: LUCENE-3723", Searcher.Similarity is TFIDFSimilarity);
SpanQuery qA1 = new SpanTermQuery(new Term("gender", "female"));
SpanQuery qA2 = new SpanTermQuery(new Term("first", "james"));
SpanQuery qA = new SpanOrQuery(qA1, new FieldMaskingSpanQuery(qA2, "gender"));
SpanQuery qB = new SpanTermQuery(new Term("last", "jones"));
SpanQuery q = new SpanNearQuery(new SpanQuery[] { new FieldMaskingSpanQuery(qA, "id"), new FieldMaskingSpanQuery(qB, "id") }, -1, false);
Check(q, new int[] { 0, 1, 2, 3 });
Spans span = MultiSpansWrapper.Wrap(Searcher.TopReaderContext, q);
Assert.AreEqual(true, span.Next());
Assert.AreEqual(s(0, 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, 2, 3), s(span));
Assert.AreEqual(true, span.Next());
Assert.AreEqual(s(3, 0, 1), s(span));
Assert.AreEqual(false, span.Next());
}
示例11: TestSpans2
public virtual void TestSpans2()
{
SpanQuery qA1 = new SpanTermQuery(new Term("gender", "female"));
SpanQuery qA2 = new SpanTermQuery(new Term("first", "james"));
SpanQuery qA = new SpanOrQuery(new SpanQuery[]{qA1, new FieldMaskingSpanQuery(qA2, "gender")});
SpanQuery qB = new SpanTermQuery(new Term("last", "jones"));
SpanQuery q = new SpanNearQuery(new SpanQuery[]{new FieldMaskingSpanQuery(qA, "id"), new FieldMaskingSpanQuery(qB, "id")}, - 1, false);
Check(q, new int[]{0, 1, 2, 3});
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, 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, 2, 3), S(span));
Assert.AreEqual(true, span.Next());
Assert.AreEqual(S(3, 0, 1), S(span));
Assert.AreEqual(false, span.Next());
}
示例12: 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");
}
示例13: 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());
}
示例14: VisitSpanOrQuery
public virtual Query VisitSpanOrQuery(SpanOrQuery spanOrq) { throw new NotImplementedException(); }
示例15: TestNoSuchMultiTermsInOr
public virtual void TestNoSuchMultiTermsInOr()
{
//test to make sure non existent multiterms aren't throwing null pointer exceptions
FuzzyQuery fuzzyNoSuch = new FuzzyQuery(new Term("field", "noSuch"), 1, 0, 1, false);
SpanQuery spanNoSuch = new SpanMultiTermQueryWrapper<MultiTermQuery>(fuzzyNoSuch);
SpanQuery term = new SpanTermQuery(new Term("field", "brown"));
SpanOrQuery near = new SpanOrQuery(new SpanQuery[] { term, spanNoSuch });
Assert.AreEqual(1, Searcher.Search(near, 10).TotalHits);
//flip
near = new SpanOrQuery(new SpanQuery[] { spanNoSuch, term });
Assert.AreEqual(1, Searcher.Search(near, 10).TotalHits);
WildcardQuery wcNoSuch = new WildcardQuery(new Term("field", "noSuch*"));
SpanQuery spanWCNoSuch = new SpanMultiTermQueryWrapper<MultiTermQuery>(wcNoSuch);
near = new SpanOrQuery(new SpanQuery[] { term, spanWCNoSuch });
Assert.AreEqual(1, Searcher.Search(near, 10).TotalHits);
RegexpQuery rgxNoSuch = new RegexpQuery(new Term("field", "noSuch"));
SpanQuery spanRgxNoSuch = new SpanMultiTermQueryWrapper<MultiTermQuery>(rgxNoSuch);
near = new SpanOrQuery(new SpanQuery[] { term, spanRgxNoSuch });
Assert.AreEqual(1, Searcher.Search(near, 10).TotalHits);
PrefixQuery prfxNoSuch = new PrefixQuery(new Term("field", "noSuch"));
SpanQuery spanPrfxNoSuch = new SpanMultiTermQueryWrapper<MultiTermQuery>(prfxNoSuch);
near = new SpanOrQuery(new SpanQuery[] { term, spanPrfxNoSuch });
Assert.AreEqual(1, Searcher.Search(near, 10).TotalHits);
near = new SpanOrQuery(new SpanQuery[] { spanPrfxNoSuch });
Assert.AreEqual(0, Searcher.Search(near, 10).TotalHits);
near = new SpanOrQuery(new SpanQuery[] { spanPrfxNoSuch, spanPrfxNoSuch });
Assert.AreEqual(0, Searcher.Search(near, 10).TotalHits);
}