Rename dataFolderPath and indexFolderPath
This commit is contained in:
parent
5139f0a38d
commit
d921d56bad
|
@ -33,14 +33,14 @@ import com.google.gson.Gson;
|
||||||
|
|
||||||
public class Indexer {
|
public class Indexer {
|
||||||
IndexWriter index;
|
IndexWriter index;
|
||||||
String dataFolderPath;
|
String dataPath;
|
||||||
String indexFolderPath;
|
String indexPath;
|
||||||
List<File> files;
|
List<File> files;
|
||||||
PerFieldAnalyzerWrapper customAnalyzer;
|
PerFieldAnalyzerWrapper customAnalyzer;
|
||||||
|
|
||||||
Indexer(String dataFolderPath, String indexFolderPath) throws IOException, ParseException {
|
Indexer(String dataPath, String indexPath) throws IOException, ParseException {
|
||||||
this.dataFolderPath = dataFolderPath;
|
this.dataPath = dataPath;
|
||||||
this.indexFolderPath = indexFolderPath;
|
this.indexPath = indexPath;
|
||||||
files = readFiles();
|
files = readFiles();
|
||||||
customAnalyzer = createAnalyzer();
|
customAnalyzer = createAnalyzer();
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ public class Indexer {
|
||||||
}
|
}
|
||||||
|
|
||||||
List<File> readFiles() throws IOException {
|
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());
|
.collect(Collectors.toList());
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ public class Indexer {
|
||||||
}
|
}
|
||||||
|
|
||||||
void createIndex() throws IOException {
|
void createIndex() throws IOException {
|
||||||
Directory dir = FSDirectory.open(Paths.get(indexFolderPath));
|
Directory dir = FSDirectory.open(Paths.get(indexPath));
|
||||||
IndexWriterConfig config = new IndexWriterConfig(customAnalyzer);
|
IndexWriterConfig config = new IndexWriterConfig(customAnalyzer);
|
||||||
config.setOpenMode(OpenMode.CREATE);
|
config.setOpenMode(OpenMode.CREATE);
|
||||||
index = new IndexWriter(dir, config);
|
index = new IndexWriter(dir, config);
|
||||||
|
@ -142,7 +142,8 @@ public class Indexer {
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
String dataDirectory = args[0];
|
String dataDirectory = args[0];
|
||||||
Indexer indexer = new Indexer(dataDirectory, ".index");
|
String indexDirectory = ".index";
|
||||||
|
Indexer indexer = new Indexer(dataDirectory, indexDirectory);
|
||||||
indexer.populateIndex();
|
indexer.populateIndex();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue