Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

call optimize at startup.

  • Loading branch information...
commit 59686cfd33c6acfb365d4ee54191310e05f342cb 1 parent e8e11e5
@rnewson authored
Showing with 12 additions and 2 deletions.
  1. +1 −1  TODO
  2. +11 −1 src/main/java/org/apache/couchdb/lucene/Index.java
View
2  TODO
@@ -3,4 +3,4 @@
* add an _optimize option.
* handle "create" and "delete" notifications explicitly.
* batch updates (no hair trigger).
-
+* reindex when transform function changes.
View
12 src/main/java/org/apache/couchdb/lucene/Index.java
@@ -47,7 +47,8 @@
public void run() {
try {
this.dir = FSDirectory.getDirectory(Config.INDEX_DIR);
-
+ Log.errlog("Optimizing index at startup.");
+ optimizeIndex();
while (running) {
updateIndex();
waitForUpdateNotification();
@@ -57,6 +58,15 @@ public void run() {
}
}
+ private void optimizeIndex() throws IOException {
+ final IndexWriter writer = newWriter();
+ try {
+ writer.optimize();
+ } finally {
+ writer.close();
+ }
+ }
+
private void updateIndex() throws IOException {
if (IndexWriter.isLocked(dir)) {
Log.errlog("Forcibly unlocking locked index at startup.");
Please sign in to comment.
Something went wrong with that request. Please try again.