本文整理汇总了C#中Lucene.Net.Index.SegmentReader.TermDocs方法的典型用法代码示例。如果您正苦于以下问题:C# SegmentReader.TermDocs方法的具体用法?C# SegmentReader.TermDocs怎么用?C# SegmentReader.TermDocs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Index.SegmentReader
的用法示例。
在下文中一共展示了SegmentReader.TermDocs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestMerge
public virtual void TestMerge()
{
//System.out.println("----------------TestMerge------------------");
SegmentMerger merger = new SegmentMerger(mergedDir, mergedSegment, false);
merger.Add(reader1);
merger.Add(reader2);
try
{
int docsMerged = merger.Merge();
merger.CloseReaders();
Assert.IsTrue(docsMerged == 2);
//Should be able to open a new SegmentReader against the new directory
SegmentReader mergedReader = new SegmentReader(new SegmentInfo(mergedSegment, docsMerged, mergedDir));
Assert.IsTrue(mergedReader != null);
Assert.IsTrue(mergedReader.NumDocs() == 2);
Document newDoc1 = mergedReader.Document(0);
Assert.IsTrue(newDoc1 != null);
//There are 2 unstored fields on the document
Assert.IsTrue(DocHelper.NumFields(newDoc1) == DocHelper.NumFields(doc1) - 2);
Document newDoc2 = mergedReader.Document(1);
Assert.IsTrue(newDoc2 != null);
Assert.IsTrue(DocHelper.NumFields(newDoc2) == DocHelper.NumFields(doc2) - 2);
TermDocs termDocs = mergedReader.TermDocs(new Term(DocHelper.TEXT_FIELD_2_KEY, "Field"));
Assert.IsTrue(termDocs != null);
Assert.IsTrue(termDocs.Next() == true);
System.Collections.ICollection stored = mergedReader.GetIndexedFieldNames(true);
Assert.IsTrue(stored != null);
//System.out.println("stored size: " + stored.size());
Assert.IsTrue(stored.Count == 2);
TermFreqVector vector = mergedReader.GetTermFreqVector(0, DocHelper.TEXT_FIELD_2_KEY);
Assert.IsTrue(vector != null);
System.String[] terms = vector.GetTerms();
Assert.IsTrue(terms != null);
//System.out.println("Terms size: " + terms.length);
Assert.IsTrue(terms.Length == 3);
int[] freqs = vector.GetTermFrequencies();
Assert.IsTrue(freqs != null);
//System.out.println("Freqs size: " + freqs.length);
for (int i = 0; i < terms.Length; i++)
{
System.String term = terms[i];
int freq = freqs[i];
//System.out.println("Term: " + term + " Freq: " + freq);
Assert.IsTrue(DocHelper.FIELD_2_TEXT.IndexOf(term) != - 1);
Assert.IsTrue(DocHelper.FIELD_2_FREQS[i] == freq);
}
}
catch (System.IO.IOException e)
{
System.Console.Error.WriteLine(e.StackTrace);
Assert.IsTrue(false);
}
//System.out.println("---------------------end TestMerge-------------------");
}