Mercurial Hosting > luan
comparison src/luan/modules/lucene/LuceneIndex.java @ 1390:179c4882c6b6
backup work
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 04 Sep 2019 00:06:42 -0600 |
parents | 2024d23ddd64 |
children | 94f48cc76de8 |
comparison
equal
deleted
inserted
replaced
1389:eb8b35dccd99 | 1390:179c4882c6b6 |
---|---|
174 if( defaultFieldParser instanceof StringFieldParser ) { | 174 if( defaultFieldParser instanceof StringFieldParser ) { |
175 StringFieldParser sfp = (StringFieldParser)defaultFieldParser; | 175 StringFieldParser sfp = (StringFieldParser)defaultFieldParser; |
176 analyzer = sfp.analyzer; | 176 analyzer = sfp.analyzer; |
177 } | 177 } |
178 this.analyzer = analyzer; | 178 this.analyzer = analyzer; |
179 reopen(); | 179 boolean wasCreated = reopen(); |
180 postgresBackup = completer!=null ? PostgresBackup.newInstance() : null; | 180 postgresBackup = completer!=null ? PostgresBackup.newInstance() : null; |
181 if( postgresBackup != null && postgresBackup.wasCreated ) | 181 if( postgresBackup != null ) { |
182 rebuild_postgres_backup(completer); | 182 if( !wasCreated && postgresBackup.wasCreated ) { |
183 } | 183 logger.error("rebuilding postgres backup"); |
184 | 184 rebuild_postgres_backup(completer); |
185 public void reopen() throws IOException { | 185 } else if( wasCreated && !postgresBackup.wasCreated ) { |
186 logger.error("restoring from postgres"); | |
187 restore_from_postgres(); | |
188 } | |
189 } | |
190 } | |
191 | |
192 public boolean reopen() throws IOException { | |
186 IndexWriterConfig conf = new IndexWriterConfig(version,analyzer); | 193 IndexWriterConfig conf = new IndexWriterConfig(version,analyzer); |
187 snapshotDeletionPolicy = new SnapshotDeletionPolicy(conf.getIndexDeletionPolicy()); | 194 snapshotDeletionPolicy = new SnapshotDeletionPolicy(conf.getIndexDeletionPolicy()); |
188 conf.setIndexDeletionPolicy(snapshotDeletionPolicy); | 195 conf.setIndexDeletionPolicy(snapshotDeletionPolicy); |
189 FSDirectory dir = FSDirectory.open(indexDir); | 196 FSDirectory dir = FSDirectory.open(indexDir); |
190 fileDir = dir.getDirectory(); | 197 fileDir = dir.getDirectory(); |
198 boolean wasCreated = !fileDir.exists(); | |
191 writer = new IndexWriter(dir,conf); | 199 writer = new IndexWriter(dir,conf); |
192 writer.commit(); // commit index creation | 200 writer.commit(); // commit index creation |
193 reader = DirectoryReader.open(dir); | 201 reader = DirectoryReader.open(dir); |
194 searcher = new IndexSearcher(reader); | 202 searcher = new IndexSearcher(reader); |
195 initId(); | 203 initId(); |
204 return wasCreated; | |
196 } | 205 } |
197 | 206 |
198 private void wrote() { | 207 private void wrote() { |
199 writeCounter.incrementAndGet(); | 208 writeCounter.incrementAndGet(); |
200 } | 209 } |