Compare commits
8 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b2f2779170 | ||
![]() |
0af6edaf16 | ||
![]() |
7fe472f5ef | ||
![]() |
3aa57d1504 | ||
![]() |
4c64055f09 | ||
![]() |
9315897e69 | ||
![]() |
079a5b901e | ||
![]() |
a0b3d51d2b |
6 changed files with 151 additions and 8 deletions
2
pom.xml
2
pom.xml
|
@ -3,7 +3,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.codelibs.fess</groupId>
|
||||
<artifactId>fess</artifactId>
|
||||
<version>13.10.3-SNAPSHOT</version>
|
||||
<version>13.10.5-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<name>Fess</name>
|
||||
<description>Fess is Full tExt Search System.</description>
|
||||
|
|
|
@ -293,13 +293,15 @@ public class AdminMaintenanceAction extends FessAdminAction {
|
|||
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);
|
||||
if (replaceAliases && !fessEsClient.updateAlias(toIndex)) {
|
||||
logger.warn("Failed to update aliases for {} and {}", fromIndex, toIndex);
|
||||
if (fessEsClient.reindex(fromIndex, toIndex, replaceAliases)) {
|
||||
if (replaceAliases && !fessEsClient.updateAlias(toIndex)) {
|
||||
logger.warn("Failed to update aliases for {} and {}", fromIndex, toIndex);
|
||||
}
|
||||
}
|
||||
}, e -> logger.warn("Failed to reindex from {} to {}", fromIndex, toIndex, e)));
|
||||
return true;
|
||||
}
|
||||
|
||||
saveError(messages -> messages.addErrorsFailedToReindex(GLOBAL, fromIndex, toIndex));
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -349,9 +349,18 @@ 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 + "\"},"
|
||||
+ "\"script\":{\"source\":\"" + ComponentUtil.getLanguageHelper().getReindexScriptSource() + "\"}}";
|
||||
try (CurlResponse response = ComponentUtil.getCurlHelper().post("/_reindex")
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
final String source = fessConfig.getIndexReindexBody()//
|
||||
.replace("__SOURCE_INDEX__", fromIndex)//
|
||||
.replace("__DEST_INDEX__", toIndex)
|
||||
.replace("__SCRIPT_SOURCE__", ComponentUtil.getLanguageHelper().getReindexScriptSource());
|
||||
final String refresh = StringUtil.isNotBlank(fessConfig.getIndexReindexRefresh()) ? fessConfig.getIndexReindexRefresh() : null;
|
||||
final String requestsPerSecond =
|
||||
StringUtil.isNotBlank(fessConfig.getIndexReindexRequestsPerSecond()) ? fessConfig.getIndexReindexRequestsPerSecond() : null;
|
||||
final String scroll = StringUtil.isNotBlank(fessConfig.getIndexReindexScroll()) ? fessConfig.getIndexReindexScroll() : null;
|
||||
final String maxDocs = StringUtil.isNotBlank(fessConfig.getIndexReindexMaxDocs()) ? fessConfig.getIndexReindexMaxDocs() : null;
|
||||
try (CurlResponse response = ComponentUtil.getCurlHelper().post("/_reindex").param("refresh", refresh)
|
||||
.param("requests_per_second", requestsPerSecond).param("scroll", scroll).param("max_docs", maxDocs)
|
||||
.param("wait_for_completion", Boolean.toString(waitForCompletion)).body(source).execute()) {
|
||||
if (response.getHttpStatusCode() == 200) {
|
||||
return true;
|
||||
|
|
|
@ -74,7 +74,7 @@ public class RoleQueryHelper {
|
|||
|
||||
protected boolean encryptedCookieValue = true;
|
||||
|
||||
protected long maxAge = 30 * 60 * 1000L; // msec
|
||||
protected long maxAge = 30 * 60; // sec
|
||||
|
||||
protected Map<String, String> cookieNameMap;
|
||||
|
||||
|
|
|
@ -717,6 +717,24 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
*/
|
||||
String INDEX_FILETYPE = "index.filetype";
|
||||
|
||||
/** The key of the configuration. e.g. {"source":{"index":"__SOURCE_INDEX__","size":100},"dest":{"index":"__DEST_INDEX__"},"script":{"source":"__SCRIPT_SOURCE__"}} */
|
||||
String INDEX_REINDEX_BODY = "index.reindex.body";
|
||||
|
||||
/** The key of the configuration. e.g. -1 */
|
||||
String INDEX_REINDEX_requests_per_second = "index.reindex.requests_per_second";
|
||||
|
||||
/** The key of the configuration. e.g. false */
|
||||
String INDEX_REINDEX_REFRESH = "index.reindex.refresh";
|
||||
|
||||
/** The key of the configuration. e.g. 1m */
|
||||
String INDEX_REINDEX_TIMEOUT = "index.reindex.timeout";
|
||||
|
||||
/** The key of the configuration. e.g. 5m */
|
||||
String INDEX_REINDEX_SCROLL = "index.reindex.scroll";
|
||||
|
||||
/** The key of the configuration. e.g. */
|
||||
String INDEX_REINDEX_max_docs = "index.reindex.max_docs";
|
||||
|
||||
/** The key of the configuration. e.g. 1000 */
|
||||
String QUERY_MAX_LENGTH = "query.max.length";
|
||||
|
||||
|
@ -3657,6 +3675,71 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
*/
|
||||
String getIndexFiletype();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'index.reindex.body'. <br>
|
||||
* The value is, e.g. {"source":{"index":"__SOURCE_INDEX__","size":100},"dest":{"index":"__DEST_INDEX__"},"script":{"source":"__SCRIPT_SOURCE__"}} <br>
|
||||
* @return The value of found property. (NotNull: if not found, exception but basically no way)
|
||||
*/
|
||||
String getIndexReindexBody();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'index.reindex.requests_per_second'. <br>
|
||||
* The value is, e.g. -1 <br>
|
||||
* @return The value of found property. (NotNull: if not found, exception but basically no way)
|
||||
*/
|
||||
String getIndexReindexRequestsPerSecond();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'index.reindex.requests_per_second' as {@link Integer}. <br>
|
||||
* The value is, e.g. -1 <br>
|
||||
* @return The value of found property. (NotNull: if not found, exception but basically no way)
|
||||
* @throws NumberFormatException When the property is not integer.
|
||||
*/
|
||||
Integer getIndexReindexRequestsPerSecondAsInteger();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'index.reindex.refresh'. <br>
|
||||
* The value is, e.g. false <br>
|
||||
* @return The value of found property. (NotNull: if not found, exception but basically no way)
|
||||
*/
|
||||
String getIndexReindexRefresh();
|
||||
|
||||
/**
|
||||
* Is the property for the key 'index.reindex.refresh' true? <br>
|
||||
* The value is, e.g. false <br>
|
||||
* @return The determination, true or false. (if not found, exception but basically no way)
|
||||
*/
|
||||
boolean isIndexReindexRefresh();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'index.reindex.timeout'. <br>
|
||||
* The value is, e.g. 1m <br>
|
||||
* @return The value of found property. (NotNull: if not found, exception but basically no way)
|
||||
*/
|
||||
String getIndexReindexTimeout();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'index.reindex.scroll'. <br>
|
||||
* The value is, e.g. 5m <br>
|
||||
* @return The value of found property. (NotNull: if not found, exception but basically no way)
|
||||
*/
|
||||
String getIndexReindexScroll();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'index.reindex.max_docs'. <br>
|
||||
* The value is, e.g. <br>
|
||||
* @return The value of found property. (NotNull: if not found, exception but basically no way)
|
||||
*/
|
||||
String getIndexReindexMaxDocs();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'index.reindex.max_docs' as {@link Integer}. <br>
|
||||
* The value is, e.g. <br>
|
||||
* @return The value of found property. (NotNull: if not found, exception but basically no way)
|
||||
* @throws NumberFormatException When the property is not integer.
|
||||
*/
|
||||
Integer getIndexReindexMaxDocsAsInteger();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'query.max.length'. <br>
|
||||
* The value is, e.g. 1000 <br>
|
||||
|
@ -7878,6 +7961,42 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
return get(FessConfig.INDEX_FILETYPE);
|
||||
}
|
||||
|
||||
public String getIndexReindexBody() {
|
||||
return get(FessConfig.INDEX_REINDEX_BODY);
|
||||
}
|
||||
|
||||
public String getIndexReindexRequestsPerSecond() {
|
||||
return get(FessConfig.INDEX_REINDEX_requests_per_second);
|
||||
}
|
||||
|
||||
public Integer getIndexReindexRequestsPerSecondAsInteger() {
|
||||
return getAsInteger(FessConfig.INDEX_REINDEX_requests_per_second);
|
||||
}
|
||||
|
||||
public String getIndexReindexRefresh() {
|
||||
return get(FessConfig.INDEX_REINDEX_REFRESH);
|
||||
}
|
||||
|
||||
public boolean isIndexReindexRefresh() {
|
||||
return is(FessConfig.INDEX_REINDEX_REFRESH);
|
||||
}
|
||||
|
||||
public String getIndexReindexTimeout() {
|
||||
return get(FessConfig.INDEX_REINDEX_TIMEOUT);
|
||||
}
|
||||
|
||||
public String getIndexReindexScroll() {
|
||||
return get(FessConfig.INDEX_REINDEX_SCROLL);
|
||||
}
|
||||
|
||||
public String getIndexReindexMaxDocs() {
|
||||
return get(FessConfig.INDEX_REINDEX_max_docs);
|
||||
}
|
||||
|
||||
public Integer getIndexReindexMaxDocsAsInteger() {
|
||||
return getAsInteger(FessConfig.INDEX_REINDEX_max_docs);
|
||||
}
|
||||
|
||||
public String getQueryMaxLength() {
|
||||
return get(FessConfig.QUERY_MAX_LENGTH);
|
||||
}
|
||||
|
@ -9779,6 +9898,13 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
defaultMap.put(FessConfig.INDEX_INDICES_TIMEOUT, "1m");
|
||||
defaultMap.put(FessConfig.INDEX_FILETYPE,
|
||||
"text/html=html\napplication/msword=word\napplication/vnd.openxmlformats-officedocument.wordprocessingml.document=word\napplication/vnd.ms-excel=excel\napplication/vnd.ms-excel.sheet.2=excel\napplication/vnd.ms-excel.sheet.3=excel\napplication/vnd.ms-excel.sheet.4=excel\napplication/vnd.ms-excel.workspace.3=excel\napplication/vnd.ms-excel.workspace.4=excel\napplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet=excel\napplication/vnd.ms-powerpoint=powerpoint\napplication/vnd.openxmlformats-officedocument.presentationml.presentation=powerpoint\napplication/vnd.oasis.opendocument.text=odt\napplication/vnd.oasis.opendocument.spreadsheet=ods\napplication/vnd.oasis.opendocument.presentation=odp\napplication/pdf=pdf\napplication/x-fictionbook+xml=fb2\napplication/e-pub+zip=epub\napplication/x-ibooks+zip=ibooks\ntext/plain=txt\napplication/rtf=rtf\napplication/vnd.ms-htmlhelp=chm\napplication/zip=zip\napplication/x-7z-comressed=7z\napplication/x-bzip=bz\napplication/x-bzip2=bz2\napplication/x-tar=tar\napplication/x-rar-compressed=rar\nvideo/3gp=3gp\nvideo/3g2=3g2\nvideo/x-msvideo=avi\nvideo/x-flv=flv\nvideo/mpeg=mpeg\nvideo/mp4=mp4\nvideo/ogv=ogv\nvideo/quicktime=qt\nvideo/x-m4v=m4v\naudio/x-aif=aif\naudio/midi=midi\naudio/mpga=mpga\naudio/mp4=mp4a\naudio/ogg=oga\naudio/x-wav=wav\nimage/webp=webp\nimage/bmp=bmp\nimage/x-icon=ico\nimage/x-icon=ico\nimage/png=png\nimage/svg+xml=svg\nimage/tiff=tiff\nimage/jpeg=jpg\n");
|
||||
defaultMap.put(FessConfig.INDEX_REINDEX_BODY,
|
||||
"{\"source\":{\"index\":\"__SOURCE_INDEX__\",\"size\":100},\"dest\":{\"index\":\"__DEST_INDEX__\"},\"script\":{\"source\":\"__SCRIPT_SOURCE__\"}}");
|
||||
defaultMap.put(FessConfig.INDEX_REINDEX_requests_per_second, "-1");
|
||||
defaultMap.put(FessConfig.INDEX_REINDEX_REFRESH, "false");
|
||||
defaultMap.put(FessConfig.INDEX_REINDEX_TIMEOUT, "1m");
|
||||
defaultMap.put(FessConfig.INDEX_REINDEX_SCROLL, "5m");
|
||||
defaultMap.put(FessConfig.INDEX_REINDEX_max_docs, "");
|
||||
defaultMap.put(FessConfig.QUERY_MAX_LENGTH, "1000");
|
||||
defaultMap.put(FessConfig.QUERY_TIMEOUT, "10000");
|
||||
defaultMap.put(FessConfig.QUERY_TIMEOUT_LOGGING, "true");
|
||||
|
|
|
@ -393,6 +393,12 @@ image/svg+xml=svg\n\
|
|||
image/tiff=tiff\n\
|
||||
image/jpeg=jpg\n\
|
||||
|
||||
index.reindex.body={"source":{"index":"__SOURCE_INDEX__","size":100},"dest":{"index":"__DEST_INDEX__"},"script":{"source":"__SCRIPT_SOURCE__"}}
|
||||
index.reindex.requests_per_second=-1
|
||||
index.reindex.refresh=false
|
||||
index.reindex.timeout=1m
|
||||
index.reindex.scroll=5m
|
||||
index.reindex.max_docs=
|
||||
|
||||
# query
|
||||
query.max.length=1000
|
||||
|
|
Loading…
Add table
Reference in a new issue