什么是“path.home”变量,我该如何设置它?

What is `path.home` variable and how do I set it?

我一直在使用 elastic4s elasticsearch 驱动程序。

尝试创建客户端时:

import com.sksamuel.elastic4s._
import org.elasticsearch.common.settings._

val esSettings = //...
val client     = ElasticClient local esSettings

我收到运行时错误:

 [IllegalStateException: path.home is not configured]

什么是 path.home
如何设置 path.home?

版本:elasticsearch-2.4.1elastic4s-2.3.1

什么是path.home

documentation可以看出,path.home是一个必须设置的变量,用于定义硬盘上存储数据的位置。

如何设置path.home

在searching/trial和错误之后,我发现path.home 不能设置在elasticsearch.yml中(如文档中所示)。当您尝试加载该新配置时,这将导致您的 elasticsearch 服务失败。

path.home 是一个 JVM 参数。

特别是-Des.path.home="~/folder/"

除了 Rhys 自己的回答,你可以在创建客户端时将 path.home 传递到设置中。

val settings = Settings.builder.put("path.home", "/home/elastic")
val = ElasticClient.local(settings)