Skip to content

Commit 6fd7e55

Browse files
committed
add inputDataPath 🚀
1 parent ca4c262 commit 6fd7e55

File tree

5 files changed

+23
-8
lines changed

5 files changed

+23
-8
lines changed

config.yaml

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
!!setting.ConfigSetting
2+
# F: Full search, scan all drivers in your pc; L: Local search, scan the paths you defined in inputDataPath
3+
searchMethod: F
4+
# if searchMethod is L, you should config inputDataPath
5+
inputDataPath:
6+
- C:\Users\neal1\project\lucene-test\test-data
27
compressFileList: null
38
excludeFilePathList: [node_modules, $RECYCLE.BIN, Program Files, Windows]
49
fileList: [docx, doc, xls, xlsx, pdf, txt]
510
hasCreateIndex: true
6-
searchMethod: F

search/src/main/java/constants/CommonConstants.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
package constants;
22

3-
import java.util.ArrayList;
4-
import java.util.Arrays;
53
import java.util.List;
64

75
public class CommonConstants {
86

9-
public static List<String> DOCFILES = new ArrayList<String>(Arrays.asList(
10-
"doc", "docx", "xls", "xlsx", "pdf", "txt"
11-
));
7+
public static List<String> DOCFILES;
8+
public static List<String> INPUT_DATA_PATH_LIST;
129
public static List<String> EXCLUDE_FILE_PATHS;
1310
public static boolean IS_OPEN_CONTEXT = true;
1411
public static String INDEX_FILE_PATH = "index";

search/src/main/java/index/IndexUtil.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ public static void executeIndex(String searchType) {
3030
totalCount += runIndexByEachPath(driver);
3131
}
3232
} else {
33-
fileBeans = FileUtil.getFolderFiles(CommonConstants.INPUT_FILE_PATH);
33+
for (String path: CommonConstants.INPUT_DATA_PATH_LIST) {
34+
totalCount += runIndexByEachPath(path);
35+
}
3436
}
3537
CommonConstants.TOTAL_FILE_NUM = String.valueOf(totalCount);
3638
BaseIndex.runIndex(fileBeans);
@@ -45,7 +47,7 @@ private static int runIndexByEachPath(String path) throws Exception {
4547
int totalNum = 0;
4648
if (files != null) {
4749
for (String file: files) {
48-
file = path + file;
50+
file = path + "\\" + file;
4951
List<FileBean> fileBeans = new ArrayList<>();
5052
fileBeans.addAll(FileUtil.getFolderFiles(file));
5153
totalNum += fileBeans.size();

ui/src/main/java/controller/Controller.java

+2
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ protected Void call() throws Exception {
8484
private void executeIndex() {
8585
ConfigSetting configSetting = ConfigController.readConfig();
8686
CommonConstants.EXCLUDE_FILE_PATHS = configSetting.getExcludeFilePathList();
87+
CommonConstants.DOCFILES = configSetting.getFileList();
88+
CommonConstants.INPUT_DATA_PATH_LIST = configSetting.getInputDataPath();
8789
IndexUtil.executeIndex(configSetting.getSearchMethod());
8890
if (configSetting.getHasCreateIndex() == false) {
8991
configSetting.setHasCreateIndex(true);

ui/src/main/java/setting/ConfigSetting.java

+10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ public class ConfigSetting {
1414

1515
private boolean hasCreateIndex;
1616

17+
private List<String> inputDataPath;
18+
1719
public String getSearchMethod() {
1820
return searchMethod;
1921
}
@@ -53,4 +55,12 @@ public boolean getHasCreateIndex() {
5355
public void setHasCreateIndex(boolean hasCreateIndex) {
5456
this.hasCreateIndex = hasCreateIndex;
5557
}
58+
59+
public List<String> getInputDataPath() {
60+
return inputDataPath;
61+
}
62+
63+
public void setInputDataPath(List<String> inputDataPath) {
64+
this.inputDataPath = inputDataPath;
65+
}
5666
}

0 commit comments

Comments
 (0)