<small id='X5J5F'></small><noframes id='X5J5F'>

      <tfoot id='X5J5F'></tfoot>

    1. <legend id='X5J5F'><style id='X5J5F'><dir id='X5J5F'><q id='X5J5F'></q></dir></style></legend>
      <i id='X5J5F'><tr id='X5J5F'><dt id='X5J5F'><q id='X5J5F'><span id='X5J5F'><b id='X5J5F'><form id='X5J5F'><ins id='X5J5F'></ins><ul id='X5J5F'></ul><sub id='X5J5F'></sub></form><legend id='X5J5F'></legend><bdo id='X5J5F'><pre id='X5J5F'><center id='X5J5F'></center></pre></bdo></b><th id='X5J5F'></th></span></q></dt></tr></i><div id='X5J5F'><tfoot id='X5J5F'></tfoot><dl id='X5J5F'><fieldset id='X5J5F'></fieldset></dl></div>
        • <bdo id='X5J5F'></bdo><ul id='X5J5F'></ul>
      1. Lucene IndexWriter 添加文档速度慢

        时间:2023-09-14
          <tbody id='doxQz'></tbody>
        <tfoot id='doxQz'></tfoot>

        <i id='doxQz'><tr id='doxQz'><dt id='doxQz'><q id='doxQz'><span id='doxQz'><b id='doxQz'><form id='doxQz'><ins id='doxQz'></ins><ul id='doxQz'></ul><sub id='doxQz'></sub></form><legend id='doxQz'></legend><bdo id='doxQz'><pre id='doxQz'><center id='doxQz'></center></pre></bdo></b><th id='doxQz'></th></span></q></dt></tr></i><div id='doxQz'><tfoot id='doxQz'></tfoot><dl id='doxQz'><fieldset id='doxQz'></fieldset></dl></div>
            <bdo id='doxQz'></bdo><ul id='doxQz'></ul>

              <small id='doxQz'></small><noframes id='doxQz'>

              <legend id='doxQz'><style id='doxQz'><dir id='doxQz'><q id='doxQz'></q></dir></style></legend>
                • 本文介绍了Lucene IndexWriter 添加文档速度慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我编写了一个小循环,将 10,000 个文档添加到 IndexWriter 中,并且花了很长时间才完成.

                  I wrote a small loop which added 10,000 documents into the IndexWriter and it took for ever to do it.

                  还有其他方法可以索引大量文档吗?

                  Is there another way to index large volumes of documents?

                  我问是因为当它上线时,它必须加载 15,000 条记录.

                  I ask because when this goes live it has to load in 15,000 records.

                  另一个问题是如何避免在重新启动 Web 应用程序时再次加载所有记录?

                  The other question is how do I prevent having to load in all the records again when the web application is restarted?

                  编辑

                  这是我使用的代码;

                  for (int t = 0; t < 10000; t++){
                      doc = new Document();
                      text = "Value" + t.toString();
                      doc.Add(new Field("Value", text, Field.Store.YES, Field.Index.TOKENIZED));
                      iwriter.AddDocument(doc);
                  };
                  

                  编辑 2

                          Analyzer analyzer = new StandardAnalyzer();
                          Directory directory = new RAMDirectory();
                  
                          IndexWriter iwriter = new IndexWriter(directory, analyzer, true);
                  
                          iwriter.SetMaxFieldLength(25000);
                  

                  然后是添加文档的代码,然后;

                  then the code to add the documents, then;

                          iwriter.Close();
                  

                  推荐答案

                  只是检查,但你在运行时没有附加调试器有吗?

                  Just checking, but you haven't got the debugger attached when you're running it have you?

                  这会严重影响添加文档时的性能.

                  This severely affects performance when adding documents.

                  在我的机器上(Lucene 2.0.0.4):

                  On my machine (Lucene 2.0.0.4):

                  使用平台目标 x86 构建:

                  Built with platform target x86:

                  • 无调试器 - 5.2 秒

                  • No debugger - 5.2 seconds

                  附加调试器 - 113.8 秒

                  Debugger attached - 113.8 seconds

                  使用平台目标 x64 构建:

                  Built with platform target x64:

                  • 无调试器 - 6.0 秒

                  • No debugger - 6.0 seconds

                  附加调试器 - 171.4 秒

                  Debugger attached - 171.4 seconds

                  在 RAMDirectory 中保存和加载索引的粗略示例:

                  Rough example of saving and loading an index to and from a RAMDirectory:

                  const int DocumentCount = 10 * 1000;
                  const string IndexFilePath = @"X:Temp	mp.idx";
                  
                  Analyzer analyzer = new StandardAnalyzer();
                  Directory ramDirectory = new RAMDirectory();
                  
                  IndexWriter indexWriter = new IndexWriter(ramDirectory, analyzer, true);
                  
                  for (int i = 0; i < DocumentCount; i++)
                  {
                      Document doc = new Document();
                      string text = "Value" + i;
                      doc.Add(new Field("Value", text, Field.Store.YES, Field.Index.TOKENIZED));
                      indexWriter.AddDocument(doc);
                  }
                  
                  indexWriter.Close();
                  
                  //Save index
                  FSDirectory fileDirectory = FSDirectory.GetDirectory(IndexFilePath, true);
                  IndexWriter fileIndexWriter = new IndexWriter(fileDirectory, analyzer, true);
                  fileIndexWriter.AddIndexes(new[] { ramDirectory });
                  fileIndexWriter.Close();
                  
                  //Load index
                  FSDirectory newFileDirectory = FSDirectory.GetDirectory(IndexFilePath, false);
                  Directory newRamDirectory = new RAMDirectory();
                  IndexWriter newIndexWriter = new IndexWriter(newRamDirectory, analyzer, true);
                  newIndexWriter.AddIndexes(new[] { newFileDirectory });
                  
                  Console.WriteLine("New index writer document count:{0}.", newIndexWriter.DocCount());
                  

                  这篇关于Lucene IndexWriter 添加文档速度慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:避免在重建期间删除当前的 Lucene.NET 索引 下一篇:当搜索中使用多个单词时,如何在 Lucene.net 中执行 AND 搜索?

                  相关文章

                    <legend id='7yHjy'><style id='7yHjy'><dir id='7yHjy'><q id='7yHjy'></q></dir></style></legend>
                  1. <i id='7yHjy'><tr id='7yHjy'><dt id='7yHjy'><q id='7yHjy'><span id='7yHjy'><b id='7yHjy'><form id='7yHjy'><ins id='7yHjy'></ins><ul id='7yHjy'></ul><sub id='7yHjy'></sub></form><legend id='7yHjy'></legend><bdo id='7yHjy'><pre id='7yHjy'><center id='7yHjy'></center></pre></bdo></b><th id='7yHjy'></th></span></q></dt></tr></i><div id='7yHjy'><tfoot id='7yHjy'></tfoot><dl id='7yHjy'><fieldset id='7yHjy'></fieldset></dl></div>

                    1. <tfoot id='7yHjy'></tfoot>
                    2. <small id='7yHjy'></small><noframes id='7yHjy'>

                      • <bdo id='7yHjy'></bdo><ul id='7yHjy'></ul>