简体   繁体   中英

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

if I am setting path.home by - .put("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"); by doing this I am getting same error - UnsatisfiedDependencyException: Error creating bean with name

I spent a huge time looking into the jar code, viz. elasticsearch-2.4.4, org.elasticsearch.node.internal.InternalSettingsPreparer.prepareEnvironment() method. The exception comes while preparing the NodeClient with nodebuilder, nodeBuilder.local(true).settings(esSettings).node().client() .The solution to this issue is providing the

-Des.default.path.home=/

in vm arguments. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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