简体   繁体   English

使用基本Java应用程序的Mac OSX El Capitan上的ElasticSearch path.home异常

[英]ElasticSearch path.home exception on Mac OSX El Capitan using basic Java app

I'm trying to get myself familiar with Elastic Search for one project, but I can't seem to get rid of an exception. 我试图使自己熟悉一个项目的Elastic Search,但似乎无法摆脱异常。 This is the basic code: 这是基本代码:

import org.elasticsearch.action.fieldstats.FieldStats;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.client.*;
import org.elasticsearch.node.Node;

import java.io.IOException;

import static org.elasticsearch.common.xcontent.XContentFactory.*;
import static org.elasticsearch.node.NodeBuilder.*;

public class Testing {

    public static void main(String[] args) throws IOException {

        Node node = nodeBuilder().node();
        Client client = node.client();

        IndexResponse response = client.prepareIndex("twitter", "tweet", "1")
                .setSource(jsonBuilder()
                                .startObject()
                                .field("user", "kimchy")
                                .field("postDate", new FieldStats.Date())
                                .field("message", "trying out Elasticsearch")
                                .endObject()
                )
                .execute()
                .actionGet();
    }
}

And this is the exception I get: 这是我得到的例外:

Exception in thread "main" java.lang.IllegalStateException: path.home is not configured
    at org.elasticsearch.env.Environment.<init>(Environment.java:99)
    at org.elasticsearch.node.internal.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:85)
    at org.elasticsearch.node.Node.<init>(Node.java:128)

I have googled quite a lot, but nowhere can I find an answer as to where to set this parameter "path.home". 我已经在Google上搜索了很多,但是在哪里可以找到关于在何处设置此参数“ path.home”的答案。 I have tried setting it in the elasticsearch.yml file both insider the project ../resources folder and inside the install folder of elasticsearch, but didn't succeed. 我尝试在项目../resources文件夹内以及elasticsearch的安装文件夹内的elasticsearch.yml文件中进行设置,但未成功。

Maybe I am a bit blind, but your help is greatly appreciated. 也许我有点盲目,但您的帮助将不胜感激。 Thank you! 谢谢!

Solved this myself. 我自己解决了。 It turned out, that I was using the BETA version 2.0 of ElasticSearch which had this problem. 原来,我使用的是ElasticSearch的BETA 2.0版,出现了此问题。 I have switched to version 1.7.2 and everything is fine now. 我已切换到1.7.2版,现在一切都很好。

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

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