使用java api在Elasticsearch中创建索引和添加映射会丢失分析器错误

代码在Scala中。 它与Java代码非常相似。

我们的地图索引器用于创建索引的代码: https : //gist.github.com/a16e5946b67c​​6d12b2b8

上述代码用于创建索引和映射的实用程序: https : //gist.github.com/4f88033204cd761abec0

java给出的错误: https : //gist.github.com/d6c835233e2b606a7074

运行代码并获取错误后对http://elasticsearch.domain/maps/_settings的响应: https ://gist.github.com/06ca7112ce1b01de3944

JSON文件: https : //gist.github.com/bbab15d699137f04ad87 https://gist.github.com/73222e300be9fffd6380

附件是我正在加载的json文件。我已经确认它正在加载正确的json文件并正确地将它作为字符串输出到.loadFromSource和.setSource。

任何想法为什么即使它们在设置中也找不到分析仪? 如果我通过curl运行这些json文件,它们工作正常并正确设置映射。

我用来创建索引的代码(在这里找到: 使用Java API定义自定义ElasticSearch Analyzer )在索引中创建设置,如:

“index.settings.analysis.filter.my_snow.type:”stemmer“,”

它在设置路径中有设置。

我将索引代码更改为以下内容以解决此问题:

def createIndex(client: Client, indexName: String, indexFile: String) { //Create index client.admin().indices().prepareCreate(indexName) .setSource(Utils.loadFileAsString(indexFile)) .execute() .actionGet() }