简体   繁体   English

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

[英]How to set path (path.home) in elastic search by node Client (not by transport)

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();
    }

if I am not setting path ie path.home I am getting error - java.lang.IllegalStateException: path.home is not configured 如果我未设置路径(即path.home),则会收到错误java.lang.IllegalStateException: path.home is not configured

if I am setting path.home by - .put("path.home", "D:\\\\elasticSearch\\\\elasticsearch-5.5.0\\\\bin"); - 如果我通过-.put(“ path.home”, "D:\\\\elasticSearch\\\\elasticsearch-5.5.0\\\\bin"); -设置path.home "D:\\\\elasticSearch\\\\elasticsearch-5.5.0\\\\bin"); - "D:\\\\elasticSearch\\\\elasticsearch-5.5.0\\\\bin"); -

I am getting error - 我遇到错误-

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"); UnsatisfiedDependencyException:创建具有名称的bean(但我不应该提供本地路径)时出错,并且如果我在类似-.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 通过这样做我得到相同的错误-UnsatisfiedDependencyException:创建具有名称的bean时出错

I spent a huge time looking into the jar code, viz. 我花了大量时间研究jar代码,即。 elasticsearch-2.4.4, org.elasticsearch.node.internal.InternalSettingsPreparer.prepareEnvironment() method. org.elasticsearch.node.internal.InternalSettingsPreparer.prepareEnvironment() -2.4.4, org.elasticsearch.node.internal.InternalSettingsPreparer.prepareEnvironment()方法。 The exception comes while preparing the NodeClient with nodebuilder, nodeBuilder.local(true).settings(esSettings).node().client() .The solution to this issue is providing the 使用nodebuilder, nodeBuilder.local(true).settings(esSettings).node().client()准备NodeClient时会出现异常。此问题的解决方案是提供

-Des.default.path.home=/ -Des.default.path.home = /

in vm arguments. 在vm参数中。 This is how the data node knows where it has to put the data. 这就是数据节点知道必须将数据放在何处的方式。 Whenever the "path.home" is not found, it is taken from vm arguments and the above property is referred. 只要找不到“ path.home”,就从vm参数中获取它,并引用上述属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM