如何在节点客户端(而非传输)弹性搜索中设置路径(path.home)

时间:2017-12-04 10:41:27

标签: java elasticsearch

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 is not configured

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

我收到错误 -

  

UnsatisfiedDependencyException:使用名称创建bean时出错(但是我   不应该给出本地路径)如果我给jar路径位置   项目如 - .put(" path.home",   " d:\ ABC \Ž\网络\目标\网络\ WEB-INF \ lib中&#34);通过这样做,我   得到相同的错误 - UnsatisfiedDependencyException:创建错误   名称为

的bean

1 个答案:

答案 0 :(得分:0)

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

  

-Des.default.path.home = /

在vm参数中。这就是数据节点如何知道放置数据的位置。每当找不到“path.home”时,都会从vm参数中获取,并引用上述属性。

相关问题