0
我想讓自己熟悉一個項目的Elastic Search,但似乎無法擺脫異常。這是基本的代碼:ElasticSearch path.home Mac OSX上的例外El Capitan使用基本的Java應用程序
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();
}
}
這是個例外,我得到:
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)
我用Google搜索了很多,但無處我能找到一個答案,在哪裏設置這個參數「 path.home」。我已經嘗試在elasticsearch.yml文件中將其設置在項目../resources文件夾和elasticsearch的安裝文件夾中,但未成功。
也許我有點失明,但你的幫助是非常感謝。 謝謝!