Skip to content

Commit

Permalink
reset
Browse files Browse the repository at this point in the history
  • Loading branch information
tlrx committed Jan 20, 2025
1 parent 7f0a8d9 commit 618274f
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
import org.apache.lucene.document.StoredField;
import org.apache.lucene.document.StringField;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexFormatTooNewException;
import org.apache.lucene.index.IndexNotFoundException;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.KeepOnlyLastCommitDeletionPolicy;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.SegmentInfos;
import org.apache.lucene.index.SerialMergeScheduler;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause;
Expand Down Expand Up @@ -418,6 +420,9 @@ static Map<String, Document> loadDocuments(NodeEnvironment nodeEnvironment) {
static Map<String, Document> loadDocuments(Path directoryPath) throws IOException {
final Map<String, Document> documents = new HashMap<>();
try (Directory directory = FSDirectory.open(directoryPath)) {
logger.fatal("bouh ");
SegmentInfos.readLatestCommit(directory);

try (IndexReader indexReader = DirectoryReader.open(directory)) {
logger.trace("loading documents from persistent cache index [{}]", directoryPath);
for (LeafReaderContext leafReaderContext : indexReader.leaves()) {
Expand All @@ -434,6 +439,14 @@ static Map<String, Document> loadDocuments(Path directoryPath) throws IOExceptio
} catch (IndexNotFoundException e) {
logger.debug("persistent cache index does not exist yet", e);
}
} catch (Exception e) {
logger.warn("persistent cache index corrupted", e);
if (e instanceof IndexFormatTooNewException) {
logger.warn("cleaning Lucene index", e);
//Lucene.cleanLuceneIndex(directory);
return Map.of();
}
throw e;
}
return documents;
}
Expand Down

0 comments on commit 618274f

Please sign in to comment.