本文整理汇总了C#中IndexWriter.AddIndexes方法的典型用法代码示例。如果您正苦于以下问题:C# IndexWriter.AddIndexes方法的具体用法?C# IndexWriter.AddIndexes怎么用?C# IndexWriter.AddIndexes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IndexWriter
的用法示例。
在下文中一共展示了IndexWriter.AddIndexes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BeforeClassSorterUtilTest
public void BeforeClassSorterUtilTest()
{
// only read the values of the undeleted documents, since after addIndexes,
// the deleted ones will be dropped from the index.
Bits liveDocs = reader.LiveDocs;
List<int> values = new List<int>();
for (int i = 0; i < reader.MaxDoc; i++)
{
if (liveDocs == null || liveDocs.Get(i))
{
values.Add(int.Parse(reader.Document(i).Get(ID_FIELD), CultureInfo.InvariantCulture));
}
}
int idx = Random().nextInt(SORT.Length);
Sort sorter = SORT[idx];
if (idx == 1)
{ // reverse doc sort
values.Reverse();
}
else
{
values.Sort();
if (Random().nextBoolean())
{
sorter = new Sort(new SortField(NUMERIC_DV_FIELD, SortField.Type_e.LONG, true)); // descending
values.Reverse();
}
}
sortedValues = values.ToArray();
if (VERBOSE)
{
Console.WriteLine("sortedValues: " + sortedValues);
Console.WriteLine("Sorter: " + sorter);
}
Directory target = NewDirectory();
using (IndexWriter writer = new IndexWriter(target, NewIndexWriterConfig(TEST_VERSION_CURRENT, null)))
{
using (reader = SortingAtomicReader.Wrap(reader, sorter))
{
writer.AddIndexes(reader);
}
}
dir.Dispose();
// CheckIndex the target directory
dir = target;
TestUtil.CheckIndex(dir);
// set reader for tests
reader = SlowCompositeReaderWrapper.Wrap(DirectoryReader.Open(dir));
assertFalse("index should not have deletions", reader.HasDeletions);
}