当前位置: 首页>>代码示例>>C#>>正文


C# IndexWriter.addIndexes方法代码示例

本文整理汇总了C#中IndexWriter.addIndexes方法的典型用法代码示例。如果您正苦于以下问题:C# IndexWriter.addIndexes方法的具体用法?C# IndexWriter.addIndexes怎么用?C# IndexWriter.addIndexes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IndexWriter的用法示例。


在下文中一共展示了IndexWriter.addIndexes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static void main(String[] args) throws java.io.IOException
	  public static void Main(string[] args)
	  {
		if (args.Length < 3)
		{
		  Console.Error.WriteLine("Usage: IndexMergeTool <mergedIndex> <index1> <index2> [index3] ...");
		  Environment.Exit(1);
		}
		FSDirectory mergedIndex = FSDirectory.open(new File(args[0]));

		IndexWriter writer = new IndexWriter(mergedIndex, new IndexWriterConfig(Version.LUCENE_CURRENT, null)
		   .setOpenMode(IndexWriterConfig.OpenMode.CREATE));

		Directory[] indexes = new Directory[args.Length - 1];
		for (int i = 1; i < args.Length; i++)
		{
		  indexes[i - 1] = FSDirectory.open(new File(args[i]));
		}

		Console.WriteLine("Merging...");
		writer.addIndexes(indexes);

		Console.WriteLine("Full merge...");
		writer.forceMerge(1);
		writer.close();
		Console.WriteLine("Done.");
	  }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:28,代码来源:IndexMergeTool.cs

示例2: createIndex

//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void createIndex(IndexWriterConfig config, org.apache.lucene.store.Directory target, IndexReader reader, org.apache.lucene.search.Filter preserveFilter, boolean negateFilter) throws java.io.IOException
	  private void createIndex(IndexWriterConfig config, Directory target, IndexReader reader, Filter preserveFilter, bool negateFilter)
	  {
		bool success = false;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final IndexWriter w = new IndexWriter(target, config);
		IndexWriter w = new IndexWriter(target, config);
		try
		{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.List<AtomicReaderContext> leaves = reader.leaves();
		  IList<AtomicReaderContext> leaves = reader.leaves();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final IndexReader[] subReaders = new IndexReader[leaves.size()];
		  IndexReader[] subReaders = new IndexReader[leaves.Count];
		  int i = 0;
		  foreach (AtomicReaderContext ctx in leaves)
		  {
			subReaders[i++] = new DocumentFilteredAtomicIndexReader(ctx, preserveFilter, negateFilter);
		  }
		  w.addIndexes(subReaders);
		  success = true;
		}
		finally
		{
		  if (success)
		  {
			IOUtils.close(w);
		  }
		  else
		  {
			IOUtils.closeWhileHandlingException(w);
		  }
		}
	  }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:36,代码来源:PKIndexSplitter.cs


注:本文中的IndexWriter.addIndexes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。