Skip to content
This repository
Browse code

Commit document changes manually and raise Solr autoCommit time.

When testing the new solr4 branch, newly uploaded documents where not
appearing in search until after solr was restarted.

This was because commit was not being called on the index.  autoCommit
was enabled, but the openSearcher option wasn't.

This extends the run interval for autoCommit to 10 minutes, and
enables autoSoftCommit every 5 minutes.  It also calls commit manually
on the index after a document is inserted or updated.

Documents will appear in the search immediately after uploading and
the somewhat expensive commit will be called less often.
  • Loading branch information...
commit e9e8ae8b51cc9e592215eff14cec5548db1dd4fd 1 parent 299d923
Nathan Stitt authored January 07, 2013
1  app/actions/document_import.rb
@@ -124,6 +124,7 @@ def process_text
124 124
     document.save!
125 125
     pages = document.reload.pages
126 126
     Sunspot.index pages
  127
+    Sunspot.commit
127 128
     DC::Import::EntityExtractor.new.extract(document, text) unless options['secure'] or not DC::Language::SUPPORTED.include? document.language
128 129
     document.upload_text_assets(pages, access)
129 130
     document.id
1  app/models/document.rb
@@ -598,6 +598,7 @@ def reindex_all!(access=nil)
598 598
     EntityDate.reset(self)
599 599
     pages = self.reload.pages
600 600
     Sunspot.index pages
  601
+    Sunspot.commit
601 602
     reprocess_entities if calais_id
602 603
     upload_text_assets(pages, access)
603 604
     self.access = access if access
14  solr/collection1/conf/solrconfig.xml
@@ -317,8 +317,9 @@
317 317
          searcher to be opened to make those changes visible.
318 318
       -->
319 319
      <autoCommit> 
320  
-       <maxTime>15000</maxTime> 
321  
-       <openSearcher>false</openSearcher> 
  320
+         <!-- 10 minutes -->
  321
+         <maxTime>600000</maxTime>
  322
+         <openSearcher>false</openSearcher>
322 323
      </autoCommit>
323 324
 
324 325
     <!-- softAutoCommit is like autoCommit except it causes a
@@ -326,11 +327,12 @@
326 327
          but does not ensure that data is synced to disk.  This is
327 328
          faster and more near-realtime friendly than a hard commit.
328 329
       -->
329  
-     <!--
330  
-       <autoSoftCommit> 
331  
-         <maxTime>1000</maxTime> 
  330
+
  331
+       <autoSoftCommit>
  332
+           <!-- 5 minutes -->
  333
+           <maxTime>300000</maxTime>
332 334
        </autoSoftCommit>
333  
-      -->
  335
+
334 336
 
335 337
     <!-- Update Related Event Listeners
336 338
          

0 notes on commit e9e8ae8

Please sign in to comment.
Something went wrong with that request. Please try again.