camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/2] git commit: CAMEL-6606: Lucene indexer should reuse existing index when starting or restarted.
Date Fri, 23 Aug 2013 10:34:32 GMT
CAMEL-6606: Lucene indexer should reuse existing index when starting or restarted.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3843f002
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3843f002
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3843f002

Branch: refs/heads/camel-2.11.x
Commit: 3843f0022690d8b98235326948bbb3aa625932d4
Parents: 7119085
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri Aug 23 12:32:59 2013 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Aug 23 12:33:22 2013 +0200

----------------------------------------------------------------------
 .../apache/camel/component/lucene/LuceneIndexer.java    | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/3843f002/components/camel-lucene/src/main/java/org/apache/camel/component/lucene/LuceneIndexer.java
----------------------------------------------------------------------
diff --git a/components/camel-lucene/src/main/java/org/apache/camel/component/lucene/LuceneIndexer.java
b/components/camel-lucene/src/main/java/org/apache/camel/component/lucene/LuceneIndexer.java
index d9b8004..4335ce6 100644
--- a/components/camel-lucene/src/main/java/org/apache/camel/component/lucene/LuceneIndexer.java
+++ b/components/camel-lucene/src/main/java/org/apache/camel/component/lucene/LuceneIndexer.java
@@ -41,8 +41,7 @@ public class LuceneIndexer {
     private NIOFSDirectory niofsDirectory;
     private IndexWriter indexWriter;
     private boolean sourceDirectoryIndexed;
-    private boolean indexCreated;
-    
+
     public LuceneIndexer(File sourceDirectory, File indexDirectory, Analyzer analyzer)  throws
Exception {
         if (indexDirectory != null) {
             if (!indexDirectory.exists()) {
@@ -144,13 +143,8 @@ public class LuceneIndexer {
 
     private void openIndexWriter() throws IOException {
         IndexWriterConfig indexWriterConfig;
-        if (!indexCreated) {
-            indexWriterConfig = new IndexWriterConfig(Version.LUCENE_36, getAnalyzer()).setOpenMode(OpenMode.CREATE);
           
-            indexWriter = new IndexWriter(niofsDirectory, indexWriterConfig);
-            indexCreated = true;
-            return;
-        }
-        indexWriterConfig = new IndexWriterConfig(Version.LUCENE_36, getAnalyzer()).setOpenMode(OpenMode.APPEND);
           
+        // use create or append so we can reuse existing index if already exists
+        indexWriterConfig = new IndexWriterConfig(Version.LUCENE_36, getAnalyzer()).setOpenMode(OpenMode.CREATE_OR_APPEND);
         indexWriter = new IndexWriter(niofsDirectory, indexWriterConfig);
     }
 


Mime
View raw message