Skip to content
Browse files

bug fix for empty indexes.

  • Loading branch information...
1 parent d98d45d commit 621d824985effd3958c5a09af7975407df49c8e1 Robert Newson committed Oct 7, 2009
Showing with 5 additions and 0 deletions.
  1. +5 −0 src/main/java/com/github/rnewson/couchdb/lucene/Indexer.java
View
5 src/main/java/com/github/rnewson/couchdb/lucene/Indexer.java
@@ -30,6 +30,7 @@
import org.apache.http.client.methods.HttpGet;
import org.apache.log4j.Logger;
import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
@@ -360,6 +361,10 @@ public Void callback(final IndexWriter writer) throws IOException {
commitUserData.put("update_seq", Long.toString(since));
commitUserData.put("uuid", uuid);
logger.debug("Committing changes to " + sig + " with " + commitUserData);
+ // commit data is not written if there are no documents.
+ if (writer.maxDoc() ==0) {
+ writer.addDocument(new Document());
+ }
writer.commit(commitUserData);
return null;
}

0 comments on commit 621d824

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