<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -27,22 +27,55 @@ UNSCHEDULED
 * JSONQuery? (http://docs.persvr.org/documentation/jsonquery)
 * geospatial (need TrieRangeQuery from 2.9)
 
-Tracking;
+Indexing Algorithm;
 
-couchdb - store {&quot;uuid&quot;:&lt;uuid&gt;} as JSON in _local/lucene
-lucene - store {&quot;update_seq&quot;:seq,&quot;uuid&quot;:&lt;uuid&gt;} as Map in userCommitData
+dbs[] = read _all_dbs
+for db in dbs
+    ddocs[] = read all design documents
+    if no fulltext functions in ddocs
+       skip this database
+    else
+	state = read db._local/lucene
+	if state is missing
+	   state = new state
+	   state.uuid = new random uuid
+	   write db._local/lucene
+	map db to state.uuid # so SearchServlet can find it
+	for ddoc in ddocs
+	    for fulltext_fun in ddoc
+	    	sig = hash(fulltext_fun)
+		map ddoc to sig # so SearchServlet can find it
+		if state.sig is missing
+		   seq = 0
+		   map state.sig to seq
+		else
+		   seq = state.sig
+         	views[] += { sig, state }
+            end for
+        end for
+        lowest_seq = smallest update_seq seen in previous loop
+	for change in changes since lowest_seq
+          for view in views
+            if (view.seq &lt; change.seq)
+              apply change to view
+          end for
+	end for
+end for
 
-Verify at startup;
 
-if couchdb_uuid != &lt; lucene_uuid then
-   // Database has been recreated.
-   delete existing index;
-   update_seq = 0;
-fi
+_local/lucene;
 
-if couchdb_uuid == lucene_uuid then
-   update_seq = &lt;value from lucene&gt;
-fi
+{
+  &quot;_id&quot;:&quot;_local/lucene&quot;,
+  &quot;uuid&quot;:&quot;&lt;uuid&gt;&quot;,
+  &quot;indexes&quot;: {
+    &quot;hash(fulltext_fun1)&quot;: {
+     update_seq: 10
+    },
+    &quot;hash(fulltext_fun2)&quot;: {
+     update_seq: 100
+    }
+  }
+}
 
-starting index from update_seq.
 </diff>
      <filename>TODO</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a3e3e5de36ac7aaab512e6322049a290f7370462</id>
    </parent>
  </parents>
  <author>
    <name>Robert Newson</name>
    <email>robert.newson@gmail.com</email>
  </author>
  <url>http://github.com/davisp/couchdb-lucene/commit/67ef1c19763c02f9ab81eca1bc721811b24bb834</url>
  <id>67ef1c19763c02f9ab81eca1bc721811b24bb834</id>
  <committed-date>2009-10-14T04:03:07-07:00</committed-date>
  <authored-date>2009-10-14T04:03:07-07:00</authored-date>
  <message>remember revised algo.</message>
  <tree>7120fa93dec4152514a6162cd98745ca633142f3</tree>
  <committer>
    <name>Robert Newson</name>
    <email>robert.newson@gmail.com</email>
  </committer>
</commit>
