<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,4 +1,6 @@
 
+v1.9.1. Add ultrasphinx:index:merge task for index merging, and a note in DEPLOYMENT_NOTES about how to use it.
+
 v1.9. Delta indexing. ERb now supported in .base files. Allow setting the searched indexes at runtime.
 
 v1.8.1. Use multifind/multiget for record loading; avoid using HashWithIndifferentAccess internally for speed; other minor performance improvements.</diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -24,6 +24,8 @@ It's easy to keep the search daemon and the indexer running in a production envi
 
 The first line reindexes the delta index every 10 minutes. The second line reindexes the main index once a day at 4am. The third line will try to restart the search daemon every three minutes. If it's already running, nothing happens. 
 
+Note that you can use &lt;tt&gt;ultrasphinx:index:merge&lt;/tt&gt; in place of &lt;tt&gt;ultrasphinx:index:main&lt;/tt&gt;. It will be faster, but will not remove deleted records from the index.
+
 Of course if you don't have any models with deltas, don't include the &lt;tt&gt;ultrasphinx:index:delta&lt;/tt&gt; task.
 
 If you are under severe memory limitations you might want to manage the daemon with Monit instead, so you can keep a closer eye on it. The search daemon is extremely reliable, so don't bother with fancy monitoring infrastructure unless you're sure you need it.</diff>
      <filename>DEPLOYMENT_NOTES</filename>
    </modified>
    <modified>
      <diff>@@ -7,6 +7,7 @@ These Rake tasks are made available to your Rails app:
 &lt;tt&gt;ultrasphinx:index&lt;/tt&gt;:: Reindex and rotate all indexes.
 &lt;tt&gt;ultrasphinx:index:delta&lt;/tt&gt;:: Reindex and rotate the delta index.
 &lt;tt&gt;ultrasphinx:index:main&lt;/tt&gt;:: Reindex and rotate the main index.
+&lt;tt&gt;ultrasphinx:index:merge&lt;/tt&gt;:: Merge the delta index into the main index.
 &lt;tt&gt;ultrasphinx:daemon:restart&lt;/tt&gt;:: Restart the search daemon.
 &lt;tt&gt;ultrasphinx:daemon:start&lt;/tt&gt;:: Start the search daemon.
 &lt;tt&gt;ultrasphinx:daemon:stop&lt;/tt&gt;:: Stop the search daemon.
@@ -14,4 +15,4 @@ These Rake tasks are made available to your Rails app:
 &lt;tt&gt;ultrasphinx:spelling:build&lt;/tt&gt;:: Rebuild the custom spelling dictionary. You may need to use &lt;tt&gt;sudo&lt;/tt&gt; if your Aspell folder is not writable by the app user.
 &lt;tt&gt;ultrasphinx:bootstrap&lt;/tt&gt;:: Bootstrap a full Sphinx environment by running configure, index, then daemon:start.
 
-All tasks have shortcuts. Use &lt;tt&gt;us:conf&lt;/tt&gt;, &lt;tt&gt;us:index&lt;/tt&gt;, &lt;tt&gt;us:main&lt;/tt&gt;, &lt;tt&gt;us:delta&lt;/tt&gt;, &lt;tt&gt;us:restart&lt;/tt&gt;, &lt;tt&gt;us:start&lt;/tt&gt;, &lt;tt&gt;us:stop&lt;/tt&gt;, &lt;tt&gt;us:stat&lt;/tt&gt;, &lt;tt&gt;us:spell&lt;/tt&gt;, and &lt;tt&gt;us:boot&lt;/tt&gt;.
\ No newline at end of file
+All tasks have shortcuts. Use &lt;tt&gt;us:conf&lt;/tt&gt;, &lt;tt&gt;us:index&lt;/tt&gt;, &lt;tt&gt;us:main&lt;/tt&gt;, &lt;tt&gt;us:delta&lt;/tt&gt;, &lt;tt&gt;us:merge&lt;/tt&gt;, &lt;tt&gt;us:restart&lt;/tt&gt;, &lt;tt&gt;us:start&lt;/tt&gt;, &lt;tt&gt;us:stop&lt;/tt&gt;, &lt;tt&gt;us:stat&lt;/tt&gt;, &lt;tt&gt;us:spell&lt;/tt&gt;, and &lt;tt&gt;us:boot&lt;/tt&gt;.
\ No newline at end of file</diff>
      <filename>RAKE_TASKS</filename>
    </modified>
    <modified>
      <diff>@@ -31,6 +31,11 @@ namespace :ultrasphinx do
       ultrasphinx_index(Ultrasphinx::DELTA_INDEX)
     end
     
+    desc &quot;Merge the delta index into the main index.&quot;
+    task :merge =&gt;  [:_environment] do
+      ultrasphinx_merge
+    end
+    
   end
 
   desc &quot;Reindex and rotate all indexes.&quot;  
@@ -121,6 +126,7 @@ namespace :us do
   task :in =&gt; [&quot;ultrasphinx:index&quot;]
   task :main =&gt; [&quot;ultrasphinx:index:main&quot;]
   task :delta =&gt; [&quot;ultrasphinx:index:delta&quot;]
+  task :merge =&gt; [&quot;ultrasphinx:index:merge&quot;]
   task :spell =&gt; [&quot;ultrasphinx:spelling:build&quot;]
   task :conf =&gt; [&quot;ultrasphinx:configure&quot;]  
   task :boot =&gt; [&quot;ultrasphinx:bootstrap&quot;]  
@@ -144,8 +150,7 @@ end
 
 def ultrasphinx_index(index)
   rotate = ultrasphinx_daemon_running?
-  index_path = Ultrasphinx::INDEX_SETTINGS['path']
-  mkdir_p index_path unless File.directory? index_path
+  ultrasphinx_create_index_path
   
   cmd = &quot;indexer --config '#{Ultrasphinx::CONF_PATH}'&quot;
   cmd &lt;&lt; &quot; #{ENV['OPTS']} &quot; if ENV['OPTS']
@@ -154,16 +159,43 @@ def ultrasphinx_index(index)
   
   say &quot;$ #{cmd}&quot;
   system cmd
+    
+  ultrasphinx_check_rotate if rotate    
+end
+
+def ultrasphinx_merge
+  rotate = ultrasphinx_daemon_running?
+
+  indexes = [Ultrasphinx::MAIN_INDEX, Ultrasphinx::DELTA_INDEX]
+  indexes.each do |index|
+    raise &quot;#{index} index is missing&quot; unless File.exist? &quot;#{Ultrasphinx::INDEX_SETTINGS['path']}/sphinx_index_#{index}.spa&quot;
+  end
+  
+  cmd = &quot;indexer --config '#{Ultrasphinx::CONF_PATH}'&quot;
+  cmd &lt;&lt; &quot; #{ENV['OPTS']} &quot; if ENV['OPTS']
+  cmd &lt;&lt; &quot; --rotate&quot; if rotate
+  cmd &lt;&lt; &quot; --merge #{indexes.join(' ')}&quot;
+  
+  say &quot;$ #{cmd}&quot;
+  system cmd
       
-  if rotate
-    sleep(4)
-    failed = Dir[index_path + &quot;/*.new.*&quot;]
-    if failed.any?
-      say &quot;warning; index failed to rotate! Deleting new indexes&quot;
-      failed.each {|f| File.delete f }
-    else
-      say &quot;index rotated ok&quot;
-    end
+  ultrasphinx_check_rotate
+end
+
+def ultrasphinx_check_rotate
+  sleep(4)
+  failed = Dir[Ultrasphinx::INDEX_SETTINGS['path'] + &quot;/*.new.*&quot;]
+  if failed.any?
+    say &quot;warning; index failed to rotate! Deleting new indexes&quot;
+    failed.each {|f| File.delete f }
+  else
+    say &quot;index rotated ok&quot;
+  end
+end
+
+def ultrasphinx_create_index_path
+  unless File.directory? Ultrasphinx::INDEX_SETTINGS['path']
+    mkdir_p Ultrasphinx::INDEX_SETTINGS['path'] 
   end
 end
 </diff>
      <filename>tasks/ultrasphinx.rake</filename>
    </modified>
    <modified>
      <diff>@@ -36,4 +36,17 @@ class DeltaTest &lt; Test::Unit::TestCase
 
     assert_equal @count, S.new.total_entries
   end
+  
+  def test_merge
+    Dir.chdir &quot;#{HERE}/integration/app&quot; do    
+      Echoe.silence do
+        system(&quot;rake ultrasphinx:daemon:start&quot;)
+      end
+
+      output = `rake ultrasphinx:index:merge 2&gt;&amp;1`
+      assert_match /merged 0.1 Kwords/, output
+      assert_match /Index rotated ok/, output
+    end
+  end  
+  
 end</diff>
      <filename>test/integration/delta_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d2f828dfb803dc73c8dcf17755574bb8e900d50f</id>
    </parent>
  </parents>
  <author>
    <name>evanweaver</name>
    <email>evanweaver@c1ad287d-65d5-445d-b84c-e64f8492f1e6</email>
  </author>
  <url>http://github.com/DrMark/ultrasphinx/commit/fbbde7fc8d3fe13039349fa3f63766b80dcbd8cf</url>
  <id>fbbde7fc8d3fe13039349fa3f63766b80dcbd8cf</id>
  <committed-date>2008-03-09T13:48:26-07:00</committed-date>
  <authored-date>2008-03-09T13:48:26-07:00</authored-date>
  <message>Add merge rake task; add test and documentation for same; DRY up some other rake configuration. 


git-svn-id: svn://rubyforge.org/var/svn/fauna/ultrasphinx/trunk@1723 c1ad287d-65d5-445d-b84c-e64f8492f1e6</message>
  <tree>a030a8e3c60bd875cb7186b78de265c28cb48b3f</tree>
  <committer>
    <name>evanweaver</name>
    <email>evanweaver@c1ad287d-65d5-445d-b84c-e64f8492f1e6</email>
  </committer>
</commit>
