gpt4 book ai didi

java - 如何通过节点客户端(而不是通过传输)在 Elasticsearch 中设置路径(path.home)

转载 作者:太空宇宙 更新时间:2023-11-04 10:52:45 25 4
gpt4 key购买 nike

if(Constants.ELASTIC_NODE_CLIENT.equals(elasticClient)) {
File tempDir = null;
try {
//Settings settings = ImmutableSettings.settingsBuilder().put("script.inline", "on").build();

Settings.Builder builder = Settings.builder()
.put("path.data", ZephyrInitializer.getElasticsearchDataDirPath())
.put("script.disable_dynamic", "false")
.put("script.inline", "on")
.put("script.indexed", "on")

for(Object prop : props.keySet()) {
String key = prop.toString();
if(!key.equals("elastic.client") && key.startsWith("elastic.")) {
String elasticKey = key.split("elastic.")[1];
builder.put(elasticKey, props.getProperty(key));
}
}

if(elasticMaxClauseCount != null) {
if(StringUtils.isNumeric(elasticMaxClauseCount)) {
builder.put("index.query.bool.max_clause_count", Integer.valueOf(elasticMaxClauseCount));
}
}

Settings settings = builder.build();

node = new Node(settings);//.clusterName(elasticClusterName).node();
client = node.client();
logger.info("Bringing up elastic search in node mode" + client);
} catch (IOException e) {
e.printStackTrace();
}

如果我没有设置路径,即path.home,我会收到错误 -java.lang.IllegalStateException:path.home未配置

如果我通过 - .put("path.home", "D:\\elasticSearch\\elasticsearch-5.5.0\\bin") 设置 path.home; -

我收到错误 -

UnsatisfiedDependencyException: Error creating bean with name (but I should not give local path) and if I am giving jar path location in project like - .put("path.home", "D:\ABC\z\web\target\web\WEB-INF\lib"); by doing this I am getting same error - UnsatisfiedDependencyException: Error creating bean with name

最佳答案

我花了很多时间研究 jar 代码,即。 elasticsearch-2.4.4,org.elasticsearch.node.internal.InternalSettingsPreparer.prepareEnvironment() 方法。使用nodebuilder准备NodeClient时出现异常,nodeBuilder.local(true).settings(esSettings).node().client()。此问题的解决方案是提供

-Des.default.path.home=/

在虚拟机参数中。这就是数据节点知道必须将数据放在哪里的方式。每当找不到“path.home”时,就会从 vm 参数中获取它并引用上述属性。

关于java - 如何通过节点客户端(而不是通过传输)在 Elasticsearch 中设置路径(path.home),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47631475/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com