From d921d56badbcad3533d0de9e22352fe66e86a0df Mon Sep 17 00:00:00 2001 From: coolneng Date: Mon, 11 Jan 2021 20:39:48 +0100 Subject: [PATCH] Rename dataFolderPath and indexFolderPath --- src/main/java/org/RI/P2/Indexer.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/RI/P2/Indexer.java b/src/main/java/org/RI/P2/Indexer.java index 6da3198..5400bbd 100644 --- a/src/main/java/org/RI/P2/Indexer.java +++ b/src/main/java/org/RI/P2/Indexer.java @@ -33,14 +33,14 @@ import com.google.gson.Gson; public class Indexer { IndexWriter index; - String dataFolderPath; - String indexFolderPath; + String dataPath; + String indexPath; List files; PerFieldAnalyzerWrapper customAnalyzer; - Indexer(String dataFolderPath, String indexFolderPath) throws IOException, ParseException { - this.dataFolderPath = dataFolderPath; - this.indexFolderPath = indexFolderPath; + Indexer(String dataPath, String indexPath) throws IOException, ParseException { + this.dataPath = dataPath; + this.indexPath = indexPath; files = readFiles(); customAnalyzer = createAnalyzer(); } @@ -59,7 +59,7 @@ public class Indexer { } List readFiles() throws IOException { - List files = Files.walk(Paths.get(dataFolderPath)).filter(Files::isRegularFile).map(Path::toFile) + List files = Files.walk(Paths.get(dataPath)).filter(Files::isRegularFile).map(Path::toFile) .collect(Collectors.toList()); return files; } @@ -73,7 +73,7 @@ public class Indexer { } void createIndex() throws IOException { - Directory dir = FSDirectory.open(Paths.get(indexFolderPath)); + Directory dir = FSDirectory.open(Paths.get(indexPath)); IndexWriterConfig config = new IndexWriterConfig(customAnalyzer); config.setOpenMode(OpenMode.CREATE); index = new IndexWriter(dir, config); @@ -142,7 +142,8 @@ public class Indexer { usage(); } String dataDirectory = args[0]; - Indexer indexer = new Indexer(dataDirectory, ".index"); + String indexDirectory = ".index"; + Indexer indexer = new Indexer(dataDirectory, indexDirectory); indexer.populateIndex(); } }