X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.indexing%2Fsrc%2Forg%2Fsimantics%2Fdb%2Findexing%2FIndexedRelationsSearcherBase.java;h=c2a7befad6e2723304b920dfc3b689c2551506e9;hb=d9361204e6d61f7defb3fb350d3751fd2c21956a;hp=136a7bcf643d689f1d5f7e6cc04206ea5aee001f;hpb=3d96e3fa94898d90d6892c081ebed7cb9e773a4a;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsSearcherBase.java b/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsSearcherBase.java index 136a7bcf6..c2a7befad 100644 --- a/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsSearcherBase.java +++ b/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsSearcherBase.java @@ -340,6 +340,7 @@ abstract public class IndexedRelationsSearcherBase { removedTerm = new Term(key, (String) keyValue); } else { // FIXME: should throw an exception for illegal input data but this would leave the index in an incoherent state + getLogger().error("Attempting to remove document from index of {} with key {} and unrecognized key value type {} : {}", input, key, keyValue, keyValue != null ? keyValue.getClass() : "null"); continue; } @@ -426,7 +427,7 @@ abstract public class IndexedRelationsSearcherBase { boolean done = false; if(requireChangeInfoOnReplace()) { TopDocs exist = searcher.search(new TermQuery(removedTerm), null, 2); - if(exist.scoreDocs.length == 1 && requireChangeInfoOnReplace()) { + if(exist.scoreDocs.length == 1) { Document doc = reader.document(exist.scoreDocs[0].doc); if(!areSame(doc, document)) { writer.deleteDocuments(removedTerm); @@ -624,7 +625,7 @@ abstract public class IndexedRelationsSearcherBase { mon.subTask("Erasing previous index"); if (getLogger().isDebugEnabled()) getLogger().debug("Erasing previous index {}", indexPath.toAbsolutePath()); - FileUtils.delete(indexPath); + FileUtils.emptyDirectory(indexPath); } } @@ -633,7 +634,7 @@ abstract public class IndexedRelationsSearcherBase { try { mon.subTask("Start index write"); - createDirectory(indexPath); + Files.createDirectories(indexPath); directory.set(FSDirectory.open(indexPath.toFile())); IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_4_9, Queries.getAnalyzer()).setOpenMode(OpenMode.CREATE); @@ -992,20 +993,14 @@ abstract public class IndexedRelationsSearcherBase { return path; } - private static void createDirectory(Path path) throws IOException { - if (Files.exists(path) && !Files.isDirectory(path)) - throw new IOException("Could not create index directory " + path + ", a file by that name already exists"); - Files.createDirectories(path); - } - Path getIndexPath() { return indexPath; } boolean isIndexAvailable() { - return (Files.exists(indexPath) && Files.isDirectory(indexPath)); + return Files.isDirectory(indexPath); } - + abstract Throwable bestEffortClear(IProgressMonitor monitor, Session session); /*