fix #1772 add reset dictionaries
This commit is contained in:
parent
8039ea97ae
commit
0b1803c63c
8 changed files with 33 additions and 7 deletions
|
@ -24,6 +24,9 @@ public class ActionForm {
|
|||
@Size(max = 10)
|
||||
public String replaceAliases = Constants.ON;
|
||||
|
||||
@Size(max = 10)
|
||||
public String resetDictionaries = Constants.ON;
|
||||
|
||||
@Size(max = 10)
|
||||
public String numberOfShardsForDoc = ComponentUtil.getFessConfig().getIndexNumberOfShards();
|
||||
|
||||
|
|
|
@ -90,7 +90,8 @@ public class AdminMaintenanceAction extends FessAdminAction {
|
|||
public HtmlResponse reindexOnly(final ActionForm form) {
|
||||
validate(form, messages -> {}, this::asIndexHtml);
|
||||
verifyToken(this::asIndexHtml);
|
||||
if (startReindex(isCheckboxEnabled(form.replaceAliases), form.numberOfShardsForDoc, form.autoExpandReplicasForDoc)) {
|
||||
if (startReindex(isCheckboxEnabled(form.replaceAliases), isCheckboxEnabled(form.resetDictionaries), form.numberOfShardsForDoc,
|
||||
form.autoExpandReplicasForDoc)) {
|
||||
saveInfo(messages -> messages.addSuccessStartedDataUpdate(GLOBAL));
|
||||
}
|
||||
return redirect(getClass());
|
||||
|
@ -258,11 +259,12 @@ public class AdminMaintenanceAction extends FessAdminAction {
|
|||
return name.endsWith(".log") || name.endsWith(".log.gz");
|
||||
}
|
||||
|
||||
protected boolean startReindex(final boolean replaceAliases, final String numberOfShards, final String autoExpandReplicas) {
|
||||
protected boolean startReindex(final boolean replaceAliases, final boolean resetDictionaries, final String numberOfShards,
|
||||
final String autoExpandReplicas) {
|
||||
final String docIndex = "fess";
|
||||
final String fromIndex = fessConfig.getIndexDocumentUpdateIndex();
|
||||
final String toIndex = docIndex + "." + new SimpleDateFormat("yyyyMMddHHmm").format(new Date());
|
||||
if (fessEsClient.createIndex(docIndex, toIndex, numberOfShards, autoExpandReplicas)) {
|
||||
if (fessEsClient.createIndex(docIndex, toIndex, numberOfShards, autoExpandReplicas, resetDictionaries)) {
|
||||
fessEsClient.admin().cluster().prepareHealth(toIndex).setWaitForYellowStatus().execute(ActionListener.wrap(response -> {
|
||||
fessEsClient.addMapping(docIndex, "doc", toIndex);
|
||||
fessEsClient.reindex(fromIndex, toIndex, replaceAliases);
|
||||
|
|
|
@ -398,14 +398,17 @@ public class FessEsClient implements Client {
|
|||
|
||||
public boolean createIndex(final String index, final String indexName) {
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
return createIndex(index, indexName, fessConfig.getIndexNumberOfShards(), fessConfig.getIndexAutoExpandReplicas());
|
||||
return createIndex(index, indexName, fessConfig.getIndexNumberOfShards(), fessConfig.getIndexAutoExpandReplicas(), true);
|
||||
}
|
||||
|
||||
public boolean createIndex(final String index, final String indexName, final String numberOfShards, final String autoExpandReplicas) {
|
||||
public boolean createIndex(final String index, final String indexName, final String numberOfShards, final String autoExpandReplicas,
|
||||
final boolean uploadConfig) {
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
|
||||
waitForConfigSyncStatus();
|
||||
sendConfigFiles(index);
|
||||
if (uploadConfig) {
|
||||
waitForConfigSyncStatus();
|
||||
sendConfigFiles(index);
|
||||
}
|
||||
|
||||
final String indexConfigFile = indexConfigPath + "/" + index + ".json";
|
||||
try {
|
||||
|
|
|
@ -2622,6 +2622,9 @@ public class FessLabels extends UserMessages {
|
|||
/** The key of the message: Update Aliases */
|
||||
public static final String LABELS_replace_aliases = "{labels.replace_aliases}";
|
||||
|
||||
/** The key of the message: Reset Dictionaries */
|
||||
public static final String LABELS_reset_dictionaries = "{labels.reset_dictionaries}";
|
||||
|
||||
/** The key of the message: Start */
|
||||
public static final String LABELS_reindex_start_button = "{labels.reindex_start_button}";
|
||||
|
||||
|
|
|
@ -864,6 +864,7 @@ labels.upgrade_data_migration=Data Migration
|
|||
labels.upgrade_reindex=Reindex
|
||||
labels.upgrade_start_button=Start
|
||||
labels.replace_aliases=Update Aliases
|
||||
labels.reset_dictionaries=Reset Dictionaries
|
||||
labels.reindex_start_button=Start
|
||||
labels.targetVersion=Version
|
||||
labels.target_version=Version From
|
||||
|
|
|
@ -864,6 +864,7 @@ labels.upgrade_data_migration=Data Migration
|
|||
labels.upgrade_reindex=Reindex
|
||||
labels.upgrade_start_button=Start
|
||||
labels.replace_aliases=Update Aliases
|
||||
labels.reset_dictionaries=Reset Dictionaries
|
||||
labels.reindex_start_button=Start
|
||||
labels.targetVersion=Version
|
||||
labels.target_version=Version From
|
||||
|
|
|
@ -866,6 +866,7 @@ labels.upgrade_data_migration=データ移行
|
|||
labels.upgrade_reindex=再インデクシング
|
||||
labels.upgrade_start_button=開始
|
||||
labels.replace_aliases=エイリアスの更新
|
||||
labels.reset_dictionaries=辞書の初期化
|
||||
labels.reindex_start_button=開始
|
||||
labels.targetVersion=対象バージョン
|
||||
labels.target_version=対象バージョン
|
||||
|
|
|
@ -51,6 +51,18 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="resetDictionaries" class="col-sm-3 control-label"><la:message
|
||||
key="labels.reset_dictionaries" /></label>
|
||||
<div class="col-sm-9">
|
||||
<la:errors property="resetDictionaries" />
|
||||
<div class="checkbox">
|
||||
<label> <la:checkbox styleId="resetDictionaries" property="resetDictionaries" /> <la:message
|
||||
key="labels.enabled" />
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="numberOfShardsForDoc" class="col-sm-3 control-label"><la:message
|
||||
key="labels.number_of_shards_for_doc" /></label>
|
||||
|
|
Loading…
Add table
Reference in a new issue