Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Solr Wiki" for change 
notification.

The following page has been changed by paulsundling:
http://wiki.apache.org/solr/EmbeddedSolr

------------------------------------------------------------------------------
  
  This program is compiled against both the Solr and Lucene JAR files.  This 
example was used with the Solr example schema and configuration.  It is run 
using a JVM system property setting {{{-Dsolr.solr.home=...}}} (point it to 
Solr'e example "solr" directory).
  
+ If processing batches of records, performance is much better if commits are 
done at intervals.  For millions of documents being added you should optimize 
after completing indexing to reduce the number of files in the index.  For 
example, 3 million documents resulted in 858 files.  See chapter 2.8 in Lucene 
in Action for more information.  To optimize, use the true flag for the 
CommitUpdateCommand.
  
  {{{
  import org.apache.solr.request.SolrRequestHandler;
@@ -104, +105 @@

      commit();
    }
  
+   private static void commit(boolean optimize) throws IOException {
+     UpdateHandler updateHandler = core.getUpdateHandler();
+     CommitUpdateCommand commitcmd = new CommitUpdateCommand(optimize);
+     updateHandler.commit(commitcmd);
+   }
+   
    private static void commit() throws IOException {
-     UpdateHandler updateHandler = core.getUpdateHandler();
-     CommitUpdateCommand commitcmd = new CommitUpdateCommand(false);
-     updateHandler.commit(commitcmd);
+     commit(false);
+   }
+ 
+   private static void optimize() throws IOException {
+     commit(true);
    }
  
    private static SolrQueryResponse search(String query) throws IOException {

Reply via email to