Rename dataFolderPath and indexFolderPath

This commit is contained in:
2021-01-11 20:39:48 +01:00
parent 5139f0a38d
commit d921d56bad

View File

@@ -33,14 +33,14 @@ import com.google.gson.Gson;
public class Indexer {
IndexWriter index;
String dataFolderPath;
String indexFolderPath;
String dataPath;
String indexPath;
List<File> 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<File> readFiles() throws IOException {
List<File> files = Files.walk(Paths.get(dataFolderPath)).filter(Files::isRegularFile).map(Path::toFile)
List<File> 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();
}
}