fix #2398 add script source
This commit is contained in:
parent
67672f25b6
commit
5b3ebc8235
2 changed files with 17 additions and 1 deletions
|
@ -349,7 +349,9 @@ public class FessEsClient implements Client {
|
|||
}
|
||||
|
||||
public boolean reindex(final String fromIndex, final String toIndex, final boolean waitForCompletion) {
|
||||
final String source = "{\"source\":{\"index\":\"" + fromIndex + "\"},\"dest\":{\"index\":\"" + toIndex + "\"}}";
|
||||
final String source =
|
||||
"{\"source\":{\"index\":\"" + fromIndex + "\"},\"dest\":{\"index\":\"" + toIndex + "\"}," + "\"script\":{\"source\":\""
|
||||
+ ComponentUtil.getLanguageHelper().getReindexScriptSource() + "\"}}";
|
||||
try (CurlResponse response =
|
||||
ComponentUtil.getCurlHelper().post("/_reindex").param("wait_for_completion", Boolean.toString(waitForCompletion))
|
||||
.body(source).execute()) {
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
*/
|
||||
package org.codelibs.fess.helper;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
|
@ -137,4 +139,16 @@ public class LanguageHelper {
|
|||
return new Script(buf.toString());
|
||||
}
|
||||
|
||||
public String getReindexScriptSource() {
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
String langField = fessConfig.getIndexFieldLang();
|
||||
String code =
|
||||
Arrays.stream(langFields).map(s -> "ctx._source['" + s + "_'+ctx._source." + langField + "]=ctx._source." + s)
|
||||
.collect(Collectors.joining(";"));
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("reindex script: {}", code);
|
||||
}
|
||||
return "if(ctx._source." + langField + "!=null){" + code + "}";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue