本文整理汇总了C#中Lucene.Net.Index.Term.Bytes方法的典型用法代码示例。如果您正苦于以下问题:C# Term.Bytes方法的具体用法?C# Term.Bytes怎么用?C# Term.Bytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Index.Term
的用法示例。
在下文中一共展示了Term.Bytes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerifyTermDocs
private void VerifyTermDocs(Directory dir, Term term, int numDocs)
{
IndexReader reader = DirectoryReader.Open(dir);
DocsEnum docsEnum = TestUtil.Docs(Random(), reader, term.Field(), term.Bytes(), null, null, DocsEnum.FLAG_NONE);
int count = 0;
while (docsEnum.NextDoc() != DocIdSetIterator.NO_MORE_DOCS)
{
count++;
}
Assert.AreEqual(numDocs, count);
reader.Dispose();
}
示例2: TotalTermFreq
/// <summary>
/// Returns the number of documents containing the term
/// <code>t</code>. this method returns 0 if the term or
/// field does not exists. this method does not take into
/// account deleted documents that have not yet been merged
/// away.
/// </summary>
public override sealed long TotalTermFreq(Term term)
{
Fields fields = Fields;
if (fields == null)
{
return 0;
}
Terms terms = fields.Terms(term.Field());
if (terms == null)
{
return 0;
}
TermsEnum termsEnum = terms.Iterator(null);
if (termsEnum.SeekExact(term.Bytes()))
{
return termsEnum.TotalTermFreq();
}
else
{
return 0;
}
}
示例3: TermPositionsEnum
/// <summary>
/// Returns <seealso cref="DocsAndPositionsEnum"/> for the specified
/// term. this will return null if the
/// field or term does not exist or positions weren't indexed. </summary>
/// <seealso cref= TermsEnum#docsAndPositions(Bits, DocsAndPositionsEnum) </seealso>
public DocsAndPositionsEnum TermPositionsEnum(Term term)
{
Debug.Assert(term.Field() != null);
Debug.Assert(term.Bytes() != null);
Fields fields = Fields;
if (fields != null)
{
Terms terms = fields.Terms(term.Field());
if (terms != null)
{
TermsEnum termsEnum = terms.Iterator(null);
if (termsEnum.SeekExact(term.Bytes()))
{
return termsEnum.DocsAndPositions(LiveDocs, null);
}
}
}
return null;
}
示例4: Build
/// <summary>
/// Creates a <seealso cref="TermContext"/> from a top-level <seealso cref="IndexReaderContext"/> and the
/// given <seealso cref="Term"/>. this method will lookup the given term in all context's leaf readers
/// and register each of the readers containing the term in the returned <seealso cref="TermContext"/>
/// using the leaf reader's ordinal.
/// <p>
/// Note: the given context must be a top-level context.
/// </summary>
public static TermContext Build(IndexReaderContext context, Term term)
{
Debug.Assert(context != null && context.IsTopLevel);
string field = term.Field();
BytesRef bytes = term.Bytes();
TermContext perReaderTermState = new TermContext(context);
//if (DEBUG) System.out.println("prts.build term=" + term);
foreach (AtomicReaderContext ctx in context.Leaves)
{
//if (DEBUG) System.out.println(" r=" + leaves[i].reader);
Fields fields = ctx.AtomicReader.Fields;
if (fields != null)
{
Terms terms = fields.Terms(field);
if (terms != null)
{
TermsEnum termsEnum = terms.Iterator(null);
if (termsEnum.SeekExact(bytes))
{
TermState termState = termsEnum.TermState();
//if (DEBUG) System.out.println(" found");
perReaderTermState.Register(termState, ctx.Ord, termsEnum.DocFreq(), termsEnum.TotalTermFreq());
}
}
}
}
return perReaderTermState;
}