Fix minor indexer bugs
diff --git a/src/main/java/de/ids_mannheim/korap/KorapIndex.java b/src/main/java/de/ids_mannheim/korap/KorapIndex.java
index fc0d31c..7492c7d 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapIndex.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapIndex.java
@@ -216,20 +216,26 @@
};
public FieldDocument addDoc (File json) throws IOException {
- FieldDocument fd = this.mapper.readValue(json, FieldDocument.class);
- return this.addDoc(fd);
+ FieldDocument fd = this.mapper.readValue(json, FieldDocument.class);
+ return this.addDoc(fd);
};
public FieldDocument addDocFile(String json) throws IOException {
- return this.addDocFile(json, false);
+ return this.addDocFile(json, false);
};
- public FieldDocument addDocFile(String json, boolean gzip) throws IOException {
+ public FieldDocument addDocFile(String json, boolean gzip) {
+ try {
if (gzip) {
- FieldDocument fd = this.mapper.readValue(new GZIPInputStream(new FileInputStream(json)), FieldDocument.class);
- return this.addDoc(fd);
+ FieldDocument fd = this.mapper.readValue(new GZIPInputStream(new FileInputStream(json)), FieldDocument.class);
+ return this.addDoc(fd);
};
return this.addDoc(json);
+ }
+ catch (IOException e) {
+ log.error("File json not found");
+ };
+ return (FieldDocument) null;
};
public void commit () throws IOException {
diff --git a/src/main/java/de/ids_mannheim/korap/KorapIndexer.java b/src/main/java/de/ids_mannheim/korap/KorapIndexer.java
index cf9355b..1bdfb8d 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapIndexer.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapIndexer.java
@@ -17,7 +17,10 @@
public KorapIndexer () throws IOException {
Properties prop = new Properties();
- FileReader fr = new FileReader(getClass().getResource("/korap.conf").getFile());
+
+ ClassLoader classLoader = getClass().getClassLoader();
+ InputStream fr = classLoader.getResourceAsStream("korap.conf");
+
prop.load(fr);
this.indexDir = prop.getProperty("lucene.index");
@@ -33,10 +36,7 @@
if (file.matches("^[^\\.].+?\\.json\\.gz$")) {
String found = dir.getPath() + '/' + file;
System.out.print(" Index " + found + " ... ");
- try {
- this.index.addDocFile(found, true);
- }
- catch (IOException e) {
+ if (this.index.addDocFile(found, true) == null) {
System.out.println("fail.");
continue;
};
diff --git a/src/main/resources/korap.conf b/src/main/resources/korap.conf
index e69de29..debbd62 100644
--- a/src/main/resources/korap.conf
+++ b/src/main/resources/korap.conf
@@ -0,0 +1,5 @@
+# Lucene Backend properties
+lucene.properties = true
+lucene.index = /home/ndiewald/Repositories/korap/KorAP-modules/KorAP-lucene-index/sandbox/index
+lucene.index.commit.count = 10000
+lucene.index.commit.log = log/korap.commit.log
\ No newline at end of file
diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j.properties
index 0b4991c..bf8fd29 100644
--- a/src/main/resources/log4j.properties
+++ b/src/main/resources/log4j.properties
@@ -1,6 +1,6 @@
## logger file can be used with
-# log4j.rootLogger = DEBUG, stdout
+log4j.rootLogger = DEBUG, stdout
#log4j.logger.de.ids_mannheim.korap.query.spans.ElementSpans = TRACE, stdout
#log4j.logger.de.ids_mannheim.korap.query.spans.WithinSpans = TRACE, stdout
@@ -9,8 +9,8 @@
#log4j.logger.de.ids_mannheim.korap.query.spans.KorapTermSpan = TRACE, stdout
#log4j.logger.de.ids_mannheim.korap.query.spans.ClassSpans = TRACE, stdout
#log4j.logger.de.ids_mannheim.korap.query.spans.MatchSpans = TRACE, stdout
-log4j.logger.de.ids_mannheim.korap.KorapIndex = TRACE, stdout
-log4j.logger.de.ids_mannheim.korap.KorapMatch = TRACE, stdout
+#log4j.logger.de.ids_mannheim.korap.KorapIndex = TRACE, stdout
+#log4j.logger.de.ids_mannheim.korap.KorapMatch = TRACE, stdout
#log4j.logger.de.ids_mannheim.korap.KorapCollection = TRACE, stdout
#log4j.logger.de.ids_mannheim.korap.index.PositionsToOffset = TRACE, stdout