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

如果我未設置路徑(即path.home),則會收到錯誤java.lang.IllegalStateException: path.home is not configured

如果我通過-.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"); -

我遇到錯誤-

UnsatisfiedDependencyException:創建具有名稱的bean(但我不應該提供本地路徑)時出錯,並且如果我在類似-.put(“ path.home”,“ D:\\ ABC \\ z \\ web \\ target \\ web \\ WEB-INF \\ lib“); 通過這樣做我得到相同的錯誤-UnsatisfiedDependencyException:創建具有名稱的bean時出錯

我花了大量時間研究jar代碼,即。 org.elasticsearch.node.internal.InternalSettingsPreparer.prepareEnvironment() -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參數中獲取它,並引用上述屬性。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM