Skip to content

Commit

Permalink
#2841 Fix fess_basic_config alias handling for Fess multi-instance su…
Browse files Browse the repository at this point in the history
…pport.
  • Loading branch information
marevol committed Aug 24, 2024
1 parent e84219b commit dd4af0d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public ActionResponse download(final String id) {
}
});
} else {
final String index;
String index;
final String filename;
if (id.endsWith(".bulk")) {
index = id.substring(0, id.length() - 5);
Expand All @@ -355,9 +355,17 @@ public ActionResponse download(final String id) {
index = id;
filename = id + ".bulk";
}
if ("fess_config".equals(index)) {
index = fessConfig.getIndexConfigIndex();
} else if ("fess_user".equals(index)) {
index = fessConfig.getIndexUserIndex();
} else if ("fess_basic_config".equals(index) && !"fess_config".equals(fessConfig.getIndexConfigIndex())) {
index = "basic_" + fessConfig.getIndexConfigIndex();
}
final String alias = index;
return asStream(filename).contentTypeOctetStream().stream(out -> {
try (final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out.stream(), Constants.CHARSET_UTF_8))) {
SearchEngineUtil.scroll(index, hit -> {
SearchEngineUtil.scroll(alias, hit -> {
try {
writer.write("{\"index\":{\"_index\":\"" + hit.getIndex() + "\",\"_id\":\""
+ StringEscapeUtils.escapeJson(hit.getId()) + "\"}}\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,11 @@ protected void createAlias(final String index, final String createdIndexName) {
}
} else if (index.startsWith(CONFIG_INDEX_PREFIX)) {
final String name = fessConfig.getIndexConfigIndex();
aliasName = aliasName.replaceFirst(Pattern.quote(CONFIG_INDEX_PREFIX), name);
if ("fess_basic_config".equals(aliasName) && !CONFIG_INDEX_PREFIX.equals(name)) {
aliasName = aliasName.replaceFirst("fess_basic_config", "basic_" + name);
} else {
aliasName = aliasName.replaceFirst(Pattern.quote(CONFIG_INDEX_PREFIX), name);
}
} else if (index.startsWith(USER_INDEX_PREFIX)) {
final String name = fessConfig.getIndexUserIndex();
aliasName = aliasName.replaceFirst(Pattern.quote(USER_INDEX_PREFIX), name);
Expand Down

0 comments on commit dd4af0d

Please sign in to comment.