#2710 replace with opensearch
This commit is contained in:
parent
f2066b6ff0
commit
5948063883
38 changed files with 130 additions and 88 deletions
|
@ -142,11 +142,11 @@ Run the `package` goal and then the release file will be created in target/relea
|
|||
|
||||
Launch Fess Server and run the following command:
|
||||
|
||||
$ mvn test -P integrationTests -Dtest.fess.url="http://localhost:8080" -Dtest.es.url="http://localhost:9201"
|
||||
$ mvn test -P integrationTests -Dtest.fess.url="http://localhost:8080" -Dtest.search_engine.url="http://localhost:9201"
|
||||
|
||||
To run a single test case, you can use:
|
||||
|
||||
$ mvn test -P integrationTests -Dtest.fess.url="http://localhost:8080" -Dtest.es.url="http://localhost:9201" -Dtest=SearchApiTests
|
||||
$ mvn test -P integrationTests -Dtest.fess.url="http://localhost:8080" -Dtest.search_engine.url="http://localhost:9201" -Dtest=SearchApiTests
|
||||
|
||||
### Translate In Your Language
|
||||
|
||||
|
|
6
deps.xml
6
deps.xml
|
@ -45,11 +45,11 @@
|
|||
</unzip>
|
||||
<!-- fess-script-groovy -->
|
||||
<antcall target="install.plugin.jar">
|
||||
<param name="repo.url" value="${maven.release.repo.url}" />
|
||||
<param name="repo.url" value="${maven.snapshot.repo.url}" />
|
||||
<param name="jar.groupId" value="org/codelibs/fess" />
|
||||
<param name="jar.artifactId" value="fess-script-groovy" />
|
||||
<param name="jar.version" value="14.5.0" />
|
||||
<param name="file.version" value="14.5.0" />
|
||||
<param name="jar.version" value="14.6.0-SNAPSHOT" />
|
||||
<param name="file.version" value="14.6.0-20230115.061716-1" />
|
||||
</antcall>
|
||||
</target>
|
||||
|
||||
|
|
|
@ -106,10 +106,10 @@ launch_service()
|
|||
|
||||
if [ "x$daemonized" = "x" ]; then
|
||||
fess_parms="$fess_parms -Dfess.foreground=yes"
|
||||
exec "$JAVA" $FESS_JAVA_OPTS $fess_parms -Dfess.es.dir="$ES_HOME" -cp "$FESS_CLASSPATH" $props \
|
||||
exec "$JAVA" $FESS_JAVA_OPTS $fess_parms -Dfess.es.dir="$SEARCH_ENGINE_HOME" -cp "$FESS_CLASSPATH" $props \
|
||||
org.codelibs.fess.FessBoot $FESS_OPTS > /dev/null
|
||||
else
|
||||
exec "$JAVA" $FESS_JAVA_OPTS $fess_parms -Dfess.es.dir="$ES_HOME" -cp "$FESS_CLASSPATH" $props \
|
||||
exec "$JAVA" $FESS_JAVA_OPTS $fess_parms -Dfess.es.dir="$SEARCH_ENGINE_HOME" -cp "$FESS_CLASSPATH" $props \
|
||||
org.codelibs.fess.FessBoot $FESS_OPTS <&- > /dev/null &
|
||||
if [ x"$pidfile" != "x" ] ; then
|
||||
echo $! > $pidfile
|
||||
|
|
|
@ -87,7 +87,7 @@ set FESS_JAVA_OPTS=%FESS_JAVA_OPTS% -Dfile.encoding=UTF-8
|
|||
|
||||
REM Application Configuration
|
||||
set APP_NAME=fess
|
||||
set ES_HOME=%FESS_HOME%/es
|
||||
set SEARCH_ENGINE_HOME=%FESS_HOME%/es
|
||||
|
||||
if NOT "%FESS_USE_GC_LOGGING%" == "" set FESS_JAVA_OPTS=%FESS_JAVA_OPTS% -Xlog:gc*,gc+age=trace,safepoint:file=%FESS_HOME%/logs/gc-%APP_NAME%.log:utctime,pid,tags:filecount=5,filesize=64m
|
||||
|
||||
|
@ -95,7 +95,7 @@ set FESS_CLASSPATH=%FESS_HOME%\lib\classes
|
|||
set FESS_JAVA_OPTS=%FESS_JAVA_OPTS% -Dfess
|
||||
set FESS_JAVA_OPTS=%FESS_JAVA_OPTS% -Des-foreground=yes
|
||||
set FESS_JAVA_OPTS=%FESS_JAVA_OPTS% -Dfess.home="%FESS_HOME%"
|
||||
set FESS_JAVA_OPTS=%FESS_JAVA_OPTS% -Dfess.es.dir="%ES_HOME%"
|
||||
set FESS_JAVA_OPTS=%FESS_JAVA_OPTS% -Dfess.es.dir="%SEARCH_ENGINE_HOME%"
|
||||
set FESS_JAVA_OPTS=%FESS_JAVA_OPTS% -Dfess.context.path=/
|
||||
set FESS_JAVA_OPTS=%FESS_JAVA_OPTS% -Dfess.port=8080
|
||||
set FESS_JAVA_OPTS=%FESS_JAVA_OPTS% -Dfess.webapp.path=%FESS_HOME%\app
|
||||
|
@ -106,8 +106,8 @@ set FESS_JAVA_OPTS=%FESS_JAVA_OPTS% -Dfess.log.level=warn
|
|||
set FESS_JAVA_OPTS=%FESS_JAVA_OPTS% -Dlasta.env=web
|
||||
set FESS_JAVA_OPTS=%FESS_JAVA_OPTS% -Dtomcat.config.path=tomcat_config.properties
|
||||
|
||||
REM External elasticsearch cluster
|
||||
REM set FESS_JAVA_OPTS=%FESS_JAVA_OPTS% -Dfess.es.http_address=http://localhost:9200
|
||||
REM set FESS_JAVA_OPTS=%FESS_JAVA_OPTS% -Dfess.dictionary.path=%ES_HOME%/config/
|
||||
REM External opensearch cluster
|
||||
REM set FESS_JAVA_OPTS=%FESS_JAVA_OPTS% -Dfess.search_engine.http_address=http://localhost:9200
|
||||
REM set FESS_JAVA_OPTS=%FESS_JAVA_OPTS% -Dfess.dictionary.path=%SEARCH_ENGINE_HOME%/config/
|
||||
|
||||
set GROOVY_TURN_OFF_JAVA_WARNINGS=true
|
||||
|
|
|
@ -21,7 +21,7 @@ if [ "x$FESS_HEAP_SIZE" != "x" ]; then
|
|||
fi
|
||||
|
||||
# External opensearch cluster
|
||||
#ES_HTTP_URL=http://localhost:9200
|
||||
#SEARCH_ENGINE_HTTP_URL=http://localhost:9200
|
||||
#FESS_DICTIONARY_PATH=/var/lib/opensearch/config/
|
||||
|
||||
# SSL truststore for certificate validation over https
|
||||
|
@ -83,8 +83,8 @@ FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfile.encoding=UTF-8"
|
|||
if [ "x$APP_NAME" = "x" ]; then
|
||||
APP_NAME=fess
|
||||
fi
|
||||
if [ "x$ES_HOME" = "x" ]; then
|
||||
ES_HOME=$FESS_HOME/es
|
||||
if [ "x$SEARCH_ENGINE_HOME" = "x" ]; then
|
||||
SEARCH_ENGINE_HOME=$FESS_HOME/es
|
||||
fi
|
||||
if [ "x$FESS_TEMP_PATH" = "x" ]; then
|
||||
FESS_TEMP_PATH=$FESS_HOME/temp
|
||||
|
@ -120,8 +120,8 @@ fi
|
|||
if [ "x$FESS_VAR_PATH" != "x" ]; then
|
||||
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.var.path=$FESS_VAR_PATH"
|
||||
fi
|
||||
if [ "x$ES_HTTP_URL" != "x" ]; then
|
||||
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.es.http_address=$ES_HTTP_URL"
|
||||
if [ "x$SEARCH_ENGINE_HTTP_URL" != "x" ]; then
|
||||
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.search_engine.http_address=$SEARCH_ENGINE_HTTP_URL"
|
||||
fi
|
||||
if [ "x$FESS_DICTIONARY_PATH" != "x" ]; then
|
||||
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.dictionary.path=$FESS_DICTIONARY_PATH"
|
||||
|
|
|
@ -141,7 +141,7 @@ CALL "%FESS_HOME%\bin\fess.in.bat"
|
|||
rem thread stack size
|
||||
set JVM_SS=256
|
||||
|
||||
set FESS_PARAMS=-Dfess;-Dfess.home="%FESS_HOME%";-Dfess.es.dir="%ES_HOME%";-Dfess.home="%FESS_HOME%";-Dfess.context.path="/";-Dfess.port=8080;-Dfess.webapp.path="%FESS_HOME%\app";-Dfess.temp.path="%FESS_HOME%\temp";-Dfess.log.name="%APP_NAME%";-Dfess.log.path="%FESS_HOME%\logs";-Dfess.log.level=warn;-Dlasta.env=web;-Dtomcat.config.path=tomcat_config.properties
|
||||
set FESS_PARAMS=-Dfess;-Dfess.home="%FESS_HOME%";-Dfess.es.dir="%SEARCH_ENGINE_HOME%";-Dfess.home="%FESS_HOME%";-Dfess.context.path="/";-Dfess.port=8080;-Dfess.webapp.path="%FESS_HOME%\app";-Dfess.temp.path="%FESS_HOME%\temp";-Dfess.log.name="%APP_NAME%";-Dfess.log.path="%FESS_HOME%\logs";-Dfess.log.level=warn;-Dlasta.env=web;-Dtomcat.config.path=tomcat_config.properties
|
||||
|
||||
set JVM_OPTS=-XX:+UseG1GC%FESS_JAVA_OPTS: =;%
|
||||
|
||||
|
|
|
@ -306,8 +306,11 @@ public class Constants extends CoreLibConstants {
|
|||
|
||||
public static final String MATCHES_ALL_QUERY = "*:*";
|
||||
|
||||
@Deprecated
|
||||
public static final String FESS_ES_HTTP_ADDRESS = "fess.es.http_address";
|
||||
|
||||
public static final String FESS_SEARCH_ENGINE_HTTP_ADDRESS = "fess.search_engine.http_address";
|
||||
|
||||
public static final int DEFAULT_PAGE_SIZE = 20;
|
||||
|
||||
public static final int DEFAULT_START_COUNT = 0;
|
||||
|
@ -340,7 +343,7 @@ public class Constants extends CoreLibConstants {
|
|||
|
||||
public static final String USER_INFO = "LoginInfo";
|
||||
|
||||
public static final String ES_API_ACCESS_TOKEN = "esApiAccessToken";
|
||||
public static final String SEARCH_ENGINE_API_ACCESS_TOKEN = "searchEngineApiAccessToken";
|
||||
|
||||
public static final String DEFAULT_FIELD = "_default";
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
package org.codelibs.fess.api.es;
|
||||
package org.codelibs.fess.api.engine;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -49,14 +49,14 @@ import org.codelibs.fess.util.ResourceUtil;
|
|||
import org.lastaflute.web.servlet.request.RequestManager;
|
||||
import org.lastaflute.web.servlet.session.SessionManager;
|
||||
|
||||
public class EsApiManager extends BaseApiManager {
|
||||
public class SearchEngineApiManager extends BaseApiManager {
|
||||
private static final String ADMIN_SERVER = "/admin/server_";
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(EsApiManager.class);
|
||||
private static final Logger logger = LogManager.getLogger(SearchEngineApiManager.class);
|
||||
|
||||
protected String[] acceptedRoles = { "admin" };
|
||||
|
||||
public EsApiManager() {
|
||||
public SearchEngineApiManager() {
|
||||
setPathPrefix(ADMIN_SERVER);
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ public class EsApiManager extends BaseApiManager {
|
|||
}
|
||||
|
||||
try {
|
||||
getSessionManager().getAttribute(Constants.ES_API_ACCESS_TOKEN, String.class).ifPresent(token -> {
|
||||
getSessionManager().getAttribute(Constants.SEARCH_ENGINE_API_ACCESS_TOKEN, String.class).ifPresent(token -> {
|
||||
final String servletPath = request.getServletPath();
|
||||
final String pathPrefix = ADMIN_SERVER + token;
|
||||
if (!servletPath.startsWith(pathPrefix)) {
|
||||
|
@ -199,12 +199,12 @@ public class EsApiManager extends BaseApiManager {
|
|||
}
|
||||
|
||||
public String getServerPath() {
|
||||
return getSessionManager().getAttribute(Constants.ES_API_ACCESS_TOKEN, String.class).map(token -> ADMIN_SERVER + token)
|
||||
return getSessionManager().getAttribute(Constants.SEARCH_ENGINE_API_ACCESS_TOKEN, String.class).map(token -> ADMIN_SERVER + token)
|
||||
.orElseThrow(() -> new FessSystemException("Cannot create an access token."));
|
||||
}
|
||||
|
||||
public void saveToken() {
|
||||
getSessionManager().setAttribute(Constants.ES_API_ACCESS_TOKEN, UUID.randomUUID().toString().replace("-", ""));
|
||||
getSessionManager().setAttribute(Constants.SEARCH_ENGINE_API_ACCESS_TOKEN, UUID.randomUUID().toString().replace("-", ""));
|
||||
}
|
||||
|
||||
private SessionManager getSessionManager() {
|
|
@ -18,7 +18,7 @@ package org.codelibs.fess.app.web.admin.dashboard;
|
|||
import javax.annotation.Resource;
|
||||
|
||||
import org.codelibs.fess.annotation.Secured;
|
||||
import org.codelibs.fess.api.es.EsApiManager;
|
||||
import org.codelibs.fess.api.engine.SearchEngineApiManager;
|
||||
import org.codelibs.fess.app.web.base.FessAdminAction;
|
||||
import org.codelibs.fess.util.RenderDataUtil;
|
||||
import org.lastaflute.web.Execute;
|
||||
|
@ -38,7 +38,7 @@ public class AdminDashboardAction extends FessAdminAction {
|
|||
// =========
|
||||
|
||||
@Resource
|
||||
protected EsApiManager esApiManager;
|
||||
protected SearchEngineApiManager searchEngineApiManager;
|
||||
|
||||
// ===================================================================================
|
||||
// Hook
|
||||
|
@ -60,9 +60,9 @@ public class AdminDashboardAction extends FessAdminAction {
|
|||
@Execute
|
||||
@Secured({ ROLE })
|
||||
public HtmlResponse index() {
|
||||
esApiManager.saveToken();
|
||||
searchEngineApiManager.saveToken();
|
||||
return asHtml(path_AdminDashboard_AdminDashboardJsp).renderWith(data -> {
|
||||
RenderDataUtil.register(data, "serverPath", esApiManager.getServerPath());
|
||||
RenderDataUtil.register(data, "serverPath", searchEngineApiManager.getServerPath());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ public class AdminMaintenanceAction extends FessAdminAction {
|
|||
//
|
||||
private static final Logger logger = LogManager.getLogger(AdminMaintenanceAction.class);
|
||||
|
||||
private static final String[] ES_CAT_NAMES =
|
||||
private static final String[] CAT_NAMES =
|
||||
{ "aliases", "allocation", "count", "fielddata", "health", "indices", "master", "nodeattrs", "nodes", "pending_tasks",
|
||||
"plugins", "recovery", "repositories", "thread_pool", "shards", "segments", "snapshots", "templates" };
|
||||
|
||||
|
@ -190,7 +190,7 @@ public class AdminMaintenanceAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
protected void writeFesenCat(final ZipOutputStream zos, final String id) {
|
||||
Arrays.stream(ES_CAT_NAMES).forEach(name -> {
|
||||
Arrays.stream(CAT_NAMES).forEach(name -> {
|
||||
final ZipEntry entry = new ZipEntry(id + "/es_cat_" + name + ".txt");
|
||||
try {
|
||||
zos.putNextEntry(entry);
|
||||
|
|
|
@ -73,6 +73,7 @@ import org.codelibs.fess.query.QueryFieldConfig;
|
|||
import org.codelibs.fess.util.BooleanFunction;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.codelibs.fess.util.DocMap;
|
||||
import org.codelibs.fess.util.SystemUtil;
|
||||
import org.codelibs.opensearch.runner.OpenSearchRunner;
|
||||
import org.codelibs.opensearch.runner.OpenSearchRunner.Configs;
|
||||
import org.dbflute.exception.IllegalBehaviorStateException;
|
||||
|
@ -259,7 +260,7 @@ public class SearchEngineClient implements Client {
|
|||
}
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
|
||||
String httpAddress = System.getProperty(Constants.FESS_ES_HTTP_ADDRESS);
|
||||
String httpAddress = SystemUtil.getSearchEngineHttpAddress();
|
||||
if (StringUtil.isBlank(httpAddress) && (runner == null)) {
|
||||
switch (fessConfig.getFesenType()) {
|
||||
case Constants.FESEN_TYPE_CLOUD:
|
||||
|
@ -295,14 +296,14 @@ public class SearchEngineClient implements Client {
|
|||
|
||||
final int port = runner.node().settings().getAsInt("http.port", 9200);
|
||||
httpAddress = "http://localhost:" + port;
|
||||
logger.warn("Embedded Fesen is running. This configuration is not recommended for production use.");
|
||||
logger.warn("Embedded OpenSearch is running. This configuration is not recommended for production use.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
client = createHttpClient(fessConfig, httpAddress);
|
||||
|
||||
if (StringUtil.isNotBlank(httpAddress)) {
|
||||
System.setProperty(Constants.FESS_ES_HTTP_ADDRESS, httpAddress);
|
||||
System.setProperty(Constants.FESS_SEARCH_ENGINE_HTTP_ADDRESS, httpAddress);
|
||||
}
|
||||
|
||||
waitForYellowStatus(fessConfig);
|
||||
|
@ -760,21 +761,20 @@ public class SearchEngineClient implements Client {
|
|||
final RestStatus status = ((OpenSearchStatusException) cause).status();
|
||||
switch (status) {
|
||||
case UNAUTHORIZED:
|
||||
logger.warn("[{}] Unauthorized access: {}", i, System.getProperty(Constants.FESS_ES_HTTP_ADDRESS), cause);
|
||||
logger.warn("[{}] Unauthorized access: {}", i, SystemUtil.getSearchEngineHttpAddress(), cause);
|
||||
break;
|
||||
default:
|
||||
logger.debug("[{}][{}] Failed to access to Fesen ({})", i, status, System.getProperty(Constants.FESS_ES_HTTP_ADDRESS),
|
||||
cause);
|
||||
logger.debug("[{}][{}] Failed to access to Fesen ({})", i, status, SystemUtil.getSearchEngineHttpAddress(), cause);
|
||||
break;
|
||||
}
|
||||
} else if (logger.isDebugEnabled()) {
|
||||
logger.debug("[{}] Failed to access to Fesen ({})", i, System.getProperty(Constants.FESS_ES_HTTP_ADDRESS), cause);
|
||||
logger.debug("[{}] Failed to access to Fesen ({})", i, SystemUtil.getSearchEngineHttpAddress(), cause);
|
||||
}
|
||||
ThreadUtil.sleep(1000L);
|
||||
}
|
||||
final String message = "Fesen (" + System.getProperty(Constants.FESS_ES_HTTP_ADDRESS)
|
||||
+ ") is not available. Check the state of your Fesen cluster (" + clusterName + ") in "
|
||||
+ (System.currentTimeMillis() - startTime) + "ms.";
|
||||
final String message =
|
||||
"Fesen (" + SystemUtil.getSearchEngineHttpAddress() + ") is not available. Check the state of your Fesen cluster ("
|
||||
+ clusterName + ") in " + (System.currentTimeMillis() - startTime) + "ms.";
|
||||
throw new ContainerInitFailureException(message, cause);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ import org.codelibs.fess.mylasta.mail.CrawlerPostcard;
|
|||
import org.codelibs.fess.timer.HotThreadMonitorTarget;
|
||||
import org.codelibs.fess.timer.SystemMonitorTarget;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.codelibs.fess.util.SystemUtil;
|
||||
import org.codelibs.fess.util.ThreadDumpUtil;
|
||||
import org.dbflute.mail.send.hook.SMailCallbackContext;
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
|
@ -210,7 +211,7 @@ public class Crawler {
|
|||
|
||||
initializeProbes();
|
||||
|
||||
final String httpAddress = System.getProperty(Constants.FESS_ES_HTTP_ADDRESS);
|
||||
final String httpAddress = SystemUtil.getSearchEngineHttpAddress();
|
||||
if (StringUtil.isNotBlank(httpAddress)) {
|
||||
System.setProperty(FesenClient.HTTP_ADDRESS, httpAddress);
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.codelibs.fess.exception.ContainerNotAvailableException;
|
|||
import org.codelibs.fess.helper.SuggestHelper;
|
||||
import org.codelibs.fess.timer.SystemMonitorTarget;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.codelibs.fess.util.SystemUtil;
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.args4j.CmdLineParser;
|
||||
import org.kohsuke.args4j.Option;
|
||||
|
@ -103,7 +104,7 @@ public class SuggestCreator {
|
|||
}
|
||||
}
|
||||
|
||||
final String httpAddress = System.getProperty(Constants.FESS_ES_HTTP_ADDRESS);
|
||||
final String httpAddress = SystemUtil.getSearchEngineHttpAddress();
|
||||
if (StringUtil.isNotBlank(httpAddress)) {
|
||||
System.setProperty(FesenClient.HTTP_ADDRESS, httpAddress);
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.codelibs.fess.es.client.SearchEngineClient;
|
|||
import org.codelibs.fess.exception.ContainerNotAvailableException;
|
||||
import org.codelibs.fess.timer.SystemMonitorTarget;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.codelibs.fess.util.SystemUtil;
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.args4j.CmdLineParser;
|
||||
import org.kohsuke.args4j.Option;
|
||||
|
@ -111,7 +112,7 @@ public class ThumbnailGenerator {
|
|||
}
|
||||
}
|
||||
|
||||
final String httpAddress = System.getProperty(Constants.FESS_ES_HTTP_ADDRESS);
|
||||
final String httpAddress = SystemUtil.getSearchEngineHttpAddress();
|
||||
if (StringUtil.isNotBlank(httpAddress)) {
|
||||
System.setProperty(FesenClient.HTTP_ADDRESS, httpAddress);
|
||||
}
|
||||
|
|
|
@ -255,7 +255,7 @@ public class QueryHelper {
|
|||
}
|
||||
|
||||
protected SortBuilder<?> createFieldSortBuilder(final String field, final SortOrder order) {
|
||||
if (QueryFieldConfig.SCORE_FIELD.equals(field) || QueryFieldConfig.ES_SCORE_FIELD.equals(field)) {
|
||||
if (QueryFieldConfig.SCORE_FIELD.equals(field) || QueryFieldConfig.DOC_SCORE_FIELD.equals(field)) {
|
||||
return SortBuilders.scoreSort().order(order);
|
||||
}
|
||||
return SortBuilders.fieldSort(field).order(order);
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.codelibs.fess.util.ComponentUtil;
|
|||
import org.codelibs.fess.util.InputStreamThread;
|
||||
import org.codelibs.fess.util.JobProcess;
|
||||
import org.codelibs.fess.util.ResourceUtil;
|
||||
import org.codelibs.fess.util.SystemUtil;
|
||||
|
||||
public class CrawlJob extends ExecJob {
|
||||
|
||||
|
@ -252,9 +253,9 @@ public class CrawlJob extends ExecJob {
|
|||
cmdList.add(buf.toString());
|
||||
|
||||
if (useLocalFesen) {
|
||||
final String httpAddress = System.getProperty(Constants.FESS_ES_HTTP_ADDRESS);
|
||||
final String httpAddress = SystemUtil.getSearchEngineHttpAddress();
|
||||
if (StringUtil.isNotBlank(httpAddress)) {
|
||||
cmdList.add("-D" + Constants.FESS_ES_HTTP_ADDRESS + "=" + httpAddress);
|
||||
cmdList.add("-D" + Constants.FESS_SEARCH_ENGINE_HTTP_ADDRESS + "=" + httpAddress);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.codelibs.fess.util.ComponentUtil;
|
|||
import org.codelibs.fess.util.InputStreamThread;
|
||||
import org.codelibs.fess.util.JobProcess;
|
||||
import org.codelibs.fess.util.ResourceUtil;
|
||||
import org.codelibs.fess.util.SystemUtil;
|
||||
|
||||
public class GenerateThumbnailJob extends ExecJob {
|
||||
static final Logger logger = LogManager.getLogger(GenerateThumbnailJob.class);
|
||||
|
@ -142,9 +143,9 @@ public class GenerateThumbnailJob extends ExecJob {
|
|||
cmdList.add(buf.toString());
|
||||
|
||||
if (useLocalFesen) {
|
||||
final String httpAddress = System.getProperty(Constants.FESS_ES_HTTP_ADDRESS);
|
||||
final String httpAddress = SystemUtil.getSearchEngineHttpAddress();
|
||||
if (StringUtil.isNotBlank(httpAddress)) {
|
||||
cmdList.add("-D" + Constants.FESS_ES_HTTP_ADDRESS + "=" + httpAddress);
|
||||
cmdList.add("-D" + Constants.FESS_SEARCH_ENGINE_HTTP_ADDRESS + "=" + httpAddress);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.codelibs.fess.mylasta.direction.FessConfig;
|
|||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.codelibs.fess.util.InputStreamThread;
|
||||
import org.codelibs.fess.util.JobProcess;
|
||||
import org.codelibs.fess.util.SystemUtil;
|
||||
|
||||
public class PythonJob extends ExecJob {
|
||||
static final Logger logger = LogManager.getLogger(PythonJob.class);
|
||||
|
@ -116,7 +117,7 @@ public class PythonJob extends ExecJob {
|
|||
pb.redirectErrorStream(true);
|
||||
final Map<String, String> environment = pb.environment();
|
||||
environment.put("SESSION_ID", sessionId);
|
||||
environment.put("OPENSEARCH_URL", System.getProperty(Constants.FESS_ES_HTTP_ADDRESS));
|
||||
environment.put("OPENSEARCH_URL", SystemUtil.getSearchEngineHttpAddress());
|
||||
});
|
||||
|
||||
final InputStreamThread it = jobProcess.getInputStreamThread();
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.codelibs.fess.util.ComponentUtil;
|
|||
import org.codelibs.fess.util.InputStreamThread;
|
||||
import org.codelibs.fess.util.JobProcess;
|
||||
import org.codelibs.fess.util.ResourceUtil;
|
||||
import org.codelibs.fess.util.SystemUtil;
|
||||
|
||||
public class SuggestJob extends ExecJob {
|
||||
|
||||
|
@ -129,9 +130,9 @@ public class SuggestJob extends ExecJob {
|
|||
cmdList.add(buf.toString());
|
||||
|
||||
if (useLocalFesen) {
|
||||
final String httpAddress = System.getProperty(Constants.FESS_ES_HTTP_ADDRESS);
|
||||
final String httpAddress = SystemUtil.getSearchEngineHttpAddress();
|
||||
if (StringUtil.isNotBlank(httpAddress)) {
|
||||
cmdList.add("-D" + Constants.FESS_ES_HTTP_ADDRESS + "=" + httpAddress);
|
||||
cmdList.add("-D" + Constants.FESS_SEARCH_ENGINE_HTTP_ADDRESS + "=" + httpAddress);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -281,7 +281,7 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
String API_JSONP_ENABLED = "api.jsonp.enabled";
|
||||
|
||||
/** The key of the configuration. e.g. status,timed_out */
|
||||
String API_PING_ES_FIELDS = "api.ping.es.fields";
|
||||
String API_PING_search_engine_FIELDS = "api.ping.search_engine.fields";
|
||||
|
||||
/** The key of the configuration. e.g. */
|
||||
String VIRTUAL_HOST_HEADERS = "virtual.host.headers";
|
||||
|
@ -2458,11 +2458,11 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
boolean isApiJsonpEnabled();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'api.ping.es.fields'. <br>
|
||||
* Get the value for the key 'api.ping.search_engine.fields'. <br>
|
||||
* The value is, e.g. status,timed_out <br>
|
||||
* @return The value of found property. (NotNull: if not found, exception but basically no way)
|
||||
*/
|
||||
String getApiPingEsFields();
|
||||
String getApiPingSearchEngineFields();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'virtual.host.headers'. <br>
|
||||
|
@ -7905,8 +7905,8 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
return is(FessConfig.API_JSONP_ENABLED);
|
||||
}
|
||||
|
||||
public String getApiPingEsFields() {
|
||||
return get(FessConfig.API_PING_ES_FIELDS);
|
||||
public String getApiPingSearchEngineFields() {
|
||||
return get(FessConfig.API_PING_search_engine_FIELDS);
|
||||
}
|
||||
|
||||
public String getVirtualHostHeaders() {
|
||||
|
@ -10712,7 +10712,7 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
defaultMap.put(FessConfig.API_CORS_ALLOW_HEADERS, "Origin, Content-Type, Accept, Authorization, X-Requested-With");
|
||||
defaultMap.put(FessConfig.API_CORS_ALLOW_CREDENTIALS, "true");
|
||||
defaultMap.put(FessConfig.API_JSONP_ENABLED, "false");
|
||||
defaultMap.put(FessConfig.API_PING_ES_FIELDS, "status,timed_out");
|
||||
defaultMap.put(FessConfig.API_PING_search_engine_FIELDS, "status,timed_out");
|
||||
defaultMap.put(FessConfig.VIRTUAL_HOST_HEADERS, "");
|
||||
defaultMap.put(FessConfig.HTTP_PROXY_HOST, "");
|
||||
defaultMap.put(FessConfig.HTTP_PROXY_PORT, "8080");
|
||||
|
|
|
@ -70,7 +70,7 @@ import org.opensearch.search.sort.SortOrder;
|
|||
|
||||
public interface FessProp {
|
||||
|
||||
String API_PING_ES_FIELD_SET = "apiPingEsFieldSet";
|
||||
String API_PING_SEARCH_ENGINE_FIELD_SET = "apiPingSearchEngineFieldSet";
|
||||
|
||||
String QUERY_HIGHLIGHT_TERMINAL_CHARS = "queryHighlightTerminalChars";
|
||||
|
||||
|
@ -2107,14 +2107,14 @@ public interface FessProp {
|
|||
.get(stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).toArray(n -> new String[n]));
|
||||
}
|
||||
|
||||
String getApiPingEsFields();
|
||||
String getApiPingSearchEngineFields();
|
||||
|
||||
default Set<String> getApiPingEsFieldSet() {
|
||||
Set<String> value = (Set<String>) propMap.get(API_PING_ES_FIELD_SET);
|
||||
Set<String> value = (Set<String>) propMap.get(API_PING_SEARCH_ENGINE_FIELD_SET);
|
||||
if (value == null) {
|
||||
value = split(getApiPingEsFields(), ",")
|
||||
value = split(getApiPingSearchEngineFields(), ",")
|
||||
.get(stream -> stream.filter(StringUtil::isNotBlank).map(String::trim).collect(Collectors.toSet()));
|
||||
propMap.put(API_PING_ES_FIELD_SET, value);
|
||||
propMap.put(API_PING_SEARCH_ENGINE_FIELD_SET, value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public abstract class QueryCommand {
|
|||
}
|
||||
|
||||
protected SortBuilder<?> createFieldSortBuilder(final String field, final SortOrder order) {
|
||||
if (QueryFieldConfig.SCORE_FIELD.equals(field) || QueryFieldConfig.ES_SCORE_FIELD.equals(field)) {
|
||||
if (QueryFieldConfig.SCORE_FIELD.equals(field) || QueryFieldConfig.DOC_SCORE_FIELD.equals(field)) {
|
||||
return SortBuilders.scoreSort().order(order);
|
||||
}
|
||||
return SortBuilders.fieldSort(field).order(order);
|
||||
|
|
|
@ -41,7 +41,7 @@ public class QueryFieldConfig {
|
|||
|
||||
public static final String SCORE_FIELD = "score";
|
||||
|
||||
public static final String ES_SCORE_FIELD = "_score";
|
||||
public static final String DOC_SCORE_FIELD = "_score";
|
||||
|
||||
public static final String SITE_FIELD = "site";
|
||||
|
||||
|
|
|
@ -168,6 +168,6 @@ public class SystemMonitorTarget extends MonitorTarget {
|
|||
} catch (final Exception e) {
|
||||
appendException(buf, e).append(',');
|
||||
}
|
||||
buf.append("\"elasticsearch\":").append(stats).append(',');
|
||||
buf.append("\"search_engine\":").append(stats).append(',');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ public final class ComponentUtil {
|
|||
|
||||
private static final String SUGGEST_HELPER = "suggestHelper";
|
||||
|
||||
private static final String FESS_ES_CLIENT = "fessEsClient";
|
||||
private static final String SEARCH_ENGINE_CLIENT = "searchEngineClient";
|
||||
|
||||
private static final String DICTIONARY_MANAGER = "dictionaryManager";
|
||||
|
||||
|
@ -381,7 +381,7 @@ public final class ComponentUtil {
|
|||
}
|
||||
|
||||
public static SearchEngineClient getSearchEngineClient() {
|
||||
return getComponent(FESS_ES_CLIENT);
|
||||
return getComponent(SEARCH_ENGINE_CLIENT);
|
||||
}
|
||||
|
||||
public static FessConfig getFessConfig() {
|
||||
|
|
|
@ -43,7 +43,7 @@ public class ResourceUtil {
|
|||
}
|
||||
|
||||
public static String getFesenHttpUrl() {
|
||||
final String url = System.getProperty(Constants.FESS_ES_HTTP_ADDRESS);
|
||||
final String url = SystemUtil.getSearchEngineHttpAddress();
|
||||
if (url != null) {
|
||||
return url;
|
||||
}
|
||||
|
|
32
src/main/java/org/codelibs/fess/util/SystemUtil.java
Normal file
32
src/main/java/org/codelibs/fess/util/SystemUtil.java
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright 2012-2023 CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
package org.codelibs.fess.util;
|
||||
|
||||
import org.codelibs.fess.Constants;
|
||||
|
||||
public class SystemUtil extends org.codelibs.core.lang.SystemUtil {
|
||||
private SystemUtil() {
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static String getSearchEngineHttpAddress() {
|
||||
final String value = System.getProperty(Constants.FESS_SEARCH_ENGINE_HTTP_ADDRESS);
|
||||
if (value != null) {
|
||||
return value;
|
||||
}
|
||||
return System.getProperty(Constants.FESS_ES_HTTP_ADDRESS);
|
||||
}
|
||||
}
|
|
@ -155,10 +155,10 @@ public final class UpgradeUtil {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static boolean addData(final Client fessEsClient, final String index, final String id, final String source) {
|
||||
public static boolean addData(final Client client, final String index, final String id, final String source) {
|
||||
try {
|
||||
final IndexRequest indexRequest = new IndexRequest(index).id(id).source(source, XContentType.JSON);
|
||||
fessEsClient.index(indexRequest).actionGet();
|
||||
client.index(indexRequest).actionGet();
|
||||
return true;
|
||||
} catch (final Exception e) {
|
||||
logger.warn("Failed to add {} to {}", id, index, e);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!DOCTYPE components PUBLIC "-//DBFLUTE//DTD LastaDi 1.0//EN"
|
||||
"http://dbflute.org/meta/lastadi10.dtd">
|
||||
<components>
|
||||
<component name="fessEsClient" class="org.codelibs.fess.es.client.SearchEngineClient">
|
||||
<component name="searchEngineClient" class="org.codelibs.fess.es.client.SearchEngineClient">
|
||||
<property name="settings">
|
||||
{"http.cors.enabled":"true",
|
||||
"http.cors.allow-origin":"*",
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
<component name="jsonApiManager" class="org.codelibs.fess.api.json.JsonApiManager">
|
||||
</component>
|
||||
<component name="esApiManager" class="org.codelibs.fess.api.es.EsApiManager">
|
||||
<component name="searchEngineApiManager" class="org.codelibs.fess.api.engine.SearchEngineApiManager">
|
||||
</component>
|
||||
<component name="suggestApiManager" class="org.codelibs.fess.api.suggest.SuggestApiManager">
|
||||
</component>
|
||||
|
|
|
@ -180,7 +180,7 @@ api.cors.max.age=3600
|
|||
api.cors.allow.headers=Origin, Content-Type, Accept, Authorization, X-Requested-With
|
||||
api.cors.allow.credentials=true
|
||||
api.jsonp.enabled=false
|
||||
api.ping.es.fields=status,timed_out
|
||||
api.ping.search_engine.fields=status,timed_out
|
||||
|
||||
|
||||
# Virtual Host: Host:fess.codelibs.org=fess
|
||||
|
|
6
src/packaging/common/env/fess
vendored
6
src/packaging/common/env/fess
vendored
|
@ -8,7 +8,7 @@ FESS_LOG_PATH=${packaging.fess.log.dir}
|
|||
FESS_CONF_PATH=${packaging.fess.conf.dir}
|
||||
FESS_VAR_PATH=${packaging.fess.var.dir}
|
||||
|
||||
FESS_DICTIONARY_PATH=/var/lib/elasticsearch/config/
|
||||
FESS_DICTIONARY_PATH=/var/lib/opensearch/config/
|
||||
|
||||
# Port
|
||||
FESS_PORT=8080
|
||||
|
@ -17,8 +17,8 @@ FESS_PORT=8080
|
|||
FESS_HEAP_SIZE=512m
|
||||
|
||||
# Elasticsearch Path
|
||||
ES_HOME=/usr/share/elasticsearch/
|
||||
SEARCH_ENGINE_HOME=/usr/share/opensearch/
|
||||
|
||||
# Elasticsearch URL
|
||||
ES_HTTP_URL=http://localhost:9200
|
||||
SEARCH_ENGINE_HTTP_URL=http://localhost:9200
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
Description=Fess
|
||||
Documentation=http://fess.codelibs.org/
|
||||
Wants=network-online.target
|
||||
After=network-online.target elasticsearch.service
|
||||
Requires=elasticsearch.service
|
||||
After=network-online.target opensearch.service
|
||||
Requires=opensearch.service
|
||||
|
||||
[Service]
|
||||
Environment=FESS_HOME=${packaging.fess.home.dir}
|
||||
|
|
|
@ -114,8 +114,8 @@ export FESS_LOG_PATH
|
|||
export FESS_CONF_PATH
|
||||
export FESS_VAR_PATH
|
||||
export FESS_DICTIONARY_PATH
|
||||
export ES_HOME
|
||||
export ES_HTTP_URL
|
||||
export SEARCH_ENGINE_HOME
|
||||
export SEARCH_ENGINE_HTTP_URL
|
||||
export FESS_JAVA_OPTS
|
||||
|
||||
# Check DAEMON exists
|
||||
|
|
|
@ -54,8 +54,8 @@ export FESS_CONF_PATH
|
|||
export FESS_VAR_PATH
|
||||
export FESS_DICTIONARY_PATH
|
||||
export FESS_HEAP_SIZE
|
||||
export ES_HOME
|
||||
export ES_HTTP_URL
|
||||
export SEARCH_ENGINE_HOME
|
||||
export SEARCH_ENGINE_HTTP_URL
|
||||
export FESS_JAVA_OPTS
|
||||
export JAVA_HOME
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ public class SynonymFileTest extends UnitFessTestCase {
|
|||
FileUtil.writeBytes(file1.getAbsolutePath(),
|
||||
"a1=>A1\nb1,b2 => B1\nc1 => C1, C2\nx1,X1\ny1, Y1, y2"
|
||||
.getBytes(Constants.UTF_8));
|
||||
// TODO set up elasticsearch and dictionaryManager
|
||||
// TODO set up opensearch and dictionaryManager
|
||||
synonymFile = new SynonymFile("1", file1.getAbsolutePath(), new Date());
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import io.restassured.specification.RequestSpecification;
|
|||
public class ITBase {
|
||||
private static final Logger logger = LogManager.getLogger(ITBase.class);
|
||||
public static final String DEFAULT_FESS_URL = "http://localhost:8080";
|
||||
public static final String DEFAULT_ES_URL = "http://localhost:9200";
|
||||
public static final String DEFAULT_SEARCH_ENGINE_URL = "http://localhost:9200";
|
||||
public static final String DEFAULT_TEST_TOKEN = "E44TjYrJQadtGBFFuECA0SBqqVtqj7lRGmhYep53ixNdvlRxnkhwqCVCpRoO";
|
||||
public static final String DEFAULT_TEST_TOKEN_ID = "testToken";
|
||||
private static final String TEST_TOKEN = "test.token";
|
||||
|
@ -70,7 +70,7 @@ public class ITBase {
|
|||
}
|
||||
|
||||
public static String getEsUrl() {
|
||||
return System.getProperty("test.es.url", DEFAULT_ES_URL);
|
||||
return System.getProperty("test.search_engine.url", DEFAULT_SEARCH_ENGINE_URL);
|
||||
}
|
||||
|
||||
protected static RequestSpecification checkMethodBase(final Map<String, Object> body) {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
tail -f ./fess-*/logs/fess-crawler.log &
|
||||
|
||||
mvn test -P integrationTests -Dtest.fess.url="http://127.0.0.1:8080" -Dtest.es.url="http://127.0.0.1:9201"
|
||||
mvn test -P integrationTests -Dtest.fess.url="http://127.0.0.1:8080" -Dtest.search_engine.url="http://127.0.0.1:9201"
|
||||
ret=$?
|
||||
|
||||
if [ $ret != 0 ] ; then
|
||||
|
|
Loading…
Add table
Reference in a new issue