本文整理汇总了C#中Lucene.Net.Search.Query.GetBoost方法的典型用法代码示例。如果您正苦于以下问题:C# Lucene.Net.Search.Query.GetBoost方法的具体用法?C# Lucene.Net.Search.Query.GetBoost怎么用?C# Lucene.Net.Search.Query.GetBoost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Search.Query
的用法示例。
在下文中一共展示了Lucene.Net.Search.Query.GetBoost方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: QueryToSpanQuery
private void QueryToSpanQuery(Query query, ICollection<byte[]> payloads)
{
if (query is BooleanQuery)
{
BooleanClause[] queryClauses = ((BooleanQuery) query).GetClauses();
for (int i = 0; i < queryClauses.Length; i++)
{
if (!queryClauses[i].IsProhibited())
{
QueryToSpanQuery(queryClauses[i].GetQuery(), payloads);
}
}
}
else if (query is PhraseQuery)
{
Term[] phraseQueryTerms = ((PhraseQuery) query).GetTerms();
SpanQuery[] clauses = new SpanQuery[phraseQueryTerms.Length];
for (int i = 0; i < phraseQueryTerms.Length; i++)
{
clauses[i] = new SpanTermQuery(phraseQueryTerms[i]);
}
int slop = ((PhraseQuery) query).GetSlop();
bool inorder = false;
if (slop == 0)
{
inorder = true;
}
SpanNearQuery sp = new SpanNearQuery(clauses, slop, inorder);
sp.SetBoost(query.GetBoost());
GetPayloads(payloads, sp);
}
else if (query is TermQuery)
{
SpanTermQuery stq = new SpanTermQuery(((TermQuery) query).GetTerm());
stq.SetBoost(query.GetBoost());
GetPayloads(payloads, stq);
}
else if (query is SpanQuery)
{
GetPayloads(payloads, (SpanQuery) query);
}
else if (query is FilteredQuery)
{
QueryToSpanQuery(((FilteredQuery) query).GetQuery(), payloads);
}
else if (query is DisjunctionMaxQuery)
{
for (System.Collections.IEnumerator iterator = ((DisjunctionMaxQuery) query).Iterator(); iterator.MoveNext(); )
{
QueryToSpanQuery((Query) iterator.Current, payloads);
}
}
else if (query is MultiPhraseQuery)
{
MultiPhraseQuery mpq = (MultiPhraseQuery) query;
System.Collections.IList termArrays = mpq.GetTermArrays();
int[] positions = mpq.GetPositions();
if (positions.Length > 0)
{
int maxPosition = positions[positions.Length - 1];
for (int i = 0; i < positions.Length - 1; ++i)
{
if (positions[i] > maxPosition)
{
maxPosition = positions[i];
}
}
System.Collections.ArrayList[] disjunctLists = new System.Collections.ArrayList[maxPosition + 1];
int distinctPositions = 0;
for (int i = 0; i < termArrays.Count; ++i)
{
Term[] termArray = (Term[]) termArrays[i];
System.Collections.IList disjuncts = disjunctLists[positions[i]];
if (disjuncts == null)
{
disjuncts = (disjunctLists[positions[i]] = new System.Collections.ArrayList(termArray.Length));
++distinctPositions;
}
for (int j = 0; j < termArray.Length; ++j)
{
disjuncts.Add(new SpanTermQuery(termArray[j]));
}
}
int positionGaps = 0;
int position = 0;
SpanQuery[] clauses = new SpanQuery[distinctPositions];
for (int i = 0; i < disjunctLists.Length; ++i)
{
System.Collections.ArrayList disjuncts = disjunctLists[i];
if (disjuncts != null)
{
//.........这里部分代码省略.........
示例2: GetTerms
//fieldname MUST be interned prior to this call
private static void GetTerms(Query query, System.Collections.Hashtable terms, bool prohibited, System.String fieldName)
{
try
{
if (query is BooleanQuery)
GetTermsFromBooleanQuery((BooleanQuery) query, terms, prohibited, fieldName);
else if (query is FilteredQuery)
GetTermsFromFilteredQuery((FilteredQuery) query, terms, prohibited, fieldName);
else
{
System.Collections.Hashtable nonWeightedTerms = new System.Collections.Hashtable();
query.ExtractTerms(nonWeightedTerms);
System.Collections.IDictionaryEnumerator iter = nonWeightedTerms.GetEnumerator();
while (iter.MoveNext())
{
Term term = (Term)iter.Value;
if ((fieldName == null) || (term.Field() == fieldName))
{
WeightedTerm temp = new WeightedTerm(query.GetBoost(), term.Text());
terms.Add(temp, temp);
}
}
}
}
catch (System.NotSupportedException ignore)
{
//this is non-fatal for our purposes
}
}