本文整理汇总了C#中Lucene.Net.Search.Spans.SpanQuery类的典型用法代码示例。如果您正苦于以下问题:C# SpanQuery类的具体用法?C# SpanQuery怎么用?C# SpanQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SpanQuery类属于Lucene.Net.Search.Spans命名空间,在下文中一共展示了SpanQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MultiSpansWrapper
private MultiSpansWrapper(IList<AtomicReaderContext> leaves, SpanQuery query, IDictionary<Term, TermContext> termContexts)
{
this.Query = query;
this.Leaves = leaves;
this.NumLeaves = leaves.Count;
this.TermContexts = termContexts;
}
示例2: VisitQuery
private static void VisitQuery(SpanQuery query, AzureQueryLogger.IndentedTextWriter writer)
{
writer.WriteLine("Field: {0}", (object)query.Field);
if (query is FieldMaskingSpanQuery)
AzureQueryLogger.VisitQuery((FieldMaskingSpanQuery)query, writer);
if (query is SpanFirstQuery)
AzureQueryLogger.VisitQuery((SpanFirstQuery)query, writer);
if (query is SpanNearQuery)
AzureQueryLogger.VisitQuery((SpanNearQuery)query, writer);
if (query is SpanNotQuery)
AzureQueryLogger.VisitQuery((SpanNotQuery)query, writer);
if (query is SpanOrQuery)
AzureQueryLogger.VisitQuery((SpanOrQuery)query, writer);
if (query is SpanRegexQuery)
AzureQueryLogger.VisitQuery((SpanRegexQuery)query, writer);
if (query is SpanTermQuery)
AzureQueryLogger.VisitQuery((SpanTermQuery)query, writer);
if (query is PayloadNearQuery)
AzureQueryLogger.VisitQuery((PayloadNearQuery)query, writer);
if (query is PayloadTermQuery)
AzureQueryLogger.VisitQuery((PayloadTermQuery)query, writer);
if (query is SpanWildcardQuery)
AzureQueryLogger.VisitQuery((SpanWildcardQuery)query, writer);
if (query is SpanLastQuery)
AzureQueryLogger.VisitQuery((SpanLastQuery)query, writer);
if (!(query is SpanFuzzyQuery))
return;
AzureQueryLogger.VisitQuery((SpanFuzzyQuery)query, writer);
}
示例3: SpanWeight
public SpanWeight(SpanQuery query, Searcher searcher)
{
this.similarity = query.GetSimilarity(searcher);
this.query = query;
this.terms = query.GetTerms();
idf = this.query.GetSimilarity(searcher).Idf(terms, searcher);
}
示例4: SpanNotQuery
/// <summary>Construct a SpanNotQuery matching spans from <c>include</c> which
/// have no overlap with spans from <c>exclude</c>.
/// </summary>
public SpanNotQuery(SpanQuery include, SpanQuery exclude)
{
this.include = include;
this.exclude = exclude;
if (!include.GetField().Equals(exclude.GetField()))
throw new System.ArgumentException("Clauses must have same field.");
}
示例5: SpanWeight
public SpanWeight(SpanQuery query, Searcher searcher)
{
this.similarity = query.GetSimilarity(searcher);
this.query = query;
terms = new Support.Set<Lucene.Net.Index.Term>();
query.ExtractTerms(terms);
idfExp = similarity.idfExplain(terms.ToArray(), searcher);
idf = idfExp.GetIdf();
}
示例6: SpanPayloadCheckQuery
///
/// <param name="match"> The underlying <seealso cref="Lucene.Net.Search.Spans.SpanQuery"/> to check </param>
/// <param name="payloadToMatch"> The <seealso cref="java.util.Collection"/> of payloads to match </param>
public SpanPayloadCheckQuery(SpanQuery match, ICollection<byte[]> payloadToMatch)
: base(match)
{
if (match is SpanNearQuery)
{
throw new System.ArgumentException("SpanNearQuery not allowed");
}
this.PayloadToMatch = payloadToMatch;
}
示例7: TestSpanNearInOrderVersusOutOfOrder
public virtual void TestSpanNearInOrderVersusOutOfOrder()
{
Term t1 = RandomTerm();
Term t2 = RandomTerm();
SpanQuery[] subquery = new SpanQuery[] { new SpanTermQuery(t1), new SpanTermQuery(t2) };
SpanNearQuery q1 = new SpanNearQuery(subquery, 3, true);
SpanNearQuery q2 = new SpanNearQuery(subquery, 3, false);
AssertSubsetOf(q1, q2);
}
示例8: SpanWeight
public SpanWeight(SpanQuery query, Searcher searcher)
{
this.similarity = query.GetSimilarity(searcher);
this.query = query;
terms = new System.Collections.Hashtable();
query.ExtractTerms(terms);
idfExp = similarity.idfExplain(new System.Collections.ArrayList(terms.Values), searcher);
idf = idfExp.GetIdf();
}
示例9: TestSpanNearVersusBooleanAnd
public virtual void TestSpanNearVersusBooleanAnd()
{
Term t1 = RandomTerm();
Term t2 = RandomTerm();
SpanQuery[] subquery = new SpanQuery[] { new SpanTermQuery(t1), new SpanTermQuery(t2) };
SpanNearQuery q1 = new SpanNearQuery(subquery, int.MaxValue, false);
BooleanQuery q2 = new BooleanQuery();
q2.Add(new TermQuery(t1), Occur.MUST);
q2.Add(new TermQuery(t2), Occur.MUST);
AssertSameSet(q1, q2);
}
示例10: TestSpanNearVersusPhrase
public virtual void TestSpanNearVersusPhrase()
{
Term t1 = RandomTerm();
Term t2 = RandomTerm();
SpanQuery[] subquery = new SpanQuery[] { new SpanTermQuery(t1), new SpanTermQuery(t2) };
SpanNearQuery q1 = new SpanNearQuery(subquery, 0, true);
PhraseQuery q2 = new PhraseQuery();
q2.Add(t1);
q2.Add(t2);
AssertSameSet(q1, q2);
}
示例11: SpanWeight
public SpanWeight(SpanQuery query, Searcher searcher)
{
this.similarity = query.GetSimilarity(searcher);
this.internalQuery = query;
terms = Lucene.Net.Support.Compatibility.SetFactory.CreateHashSet<Term>();
query.ExtractTerms(terms);
idfExp = similarity.IdfExplain(terms, searcher);
idf = idfExp.Idf;
}
示例12: SpanWeight
public SpanWeight(SpanQuery query, Searcher searcher)
{
this.similarity = query.GetSimilarity(searcher);
this.query = query;
terms = new System.Collections.Hashtable();
query.ExtractTerms(terms);
System.Collections.ArrayList tmp = new System.Collections.ArrayList(terms.Values);
idf = this.query.GetSimilarity(searcher).Idf(tmp, searcher);
}
示例13: SpanNotQuery
/// <summary>
/// Construct a SpanNotQuery matching spans from <code>include</code> which
/// have no overlap with spans from <code>exclude</code> within
/// <code>pre</code> tokens before or <code>post</code> tokens of <code>include</code>.
/// </summary>
public SpanNotQuery(SpanQuery include, SpanQuery exclude, int pre, int post)
{
this.include = include;
this.exclude = exclude;
this.Pre = (pre >= 0) ? pre : 0;
this.Post = (post >= 0) ? post : 0;
if (include.Field != null && exclude.Field != null && !include.Field.Equals(exclude.Field))
{
throw new System.ArgumentException("Clauses must have same field.");
}
}
示例14: 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;
}
示例15: Wrap
public static Spans Wrap(IndexReaderContext topLevelReaderContext, SpanQuery query)
{
IDictionary<Term, TermContext> termContexts = new Dictionary<Term, TermContext>();
SortedSet<Term> terms = new SortedSet<Term>();
query.ExtractTerms(terms);
foreach (Term term in terms)
{
termContexts[term] = TermContext.Build(topLevelReaderContext, term);
}
IList<AtomicReaderContext> leaves = topLevelReaderContext.Leaves();
if (leaves.Count == 1)
{
AtomicReaderContext ctx = leaves[0];
return query.GetSpans(ctx, ((AtomicReader)ctx.Reader()).LiveDocs, termContexts);
}
return new MultiSpansWrapper(leaves, query, termContexts);
}