使用java api创建索引并在Elasticsearch中添加映射会丢失分析器错误 [英] Creating index and adding mapping in Elasticsearch with java api gives missing analyzer errors

查看:196
本文介绍了使用java api创建索引并在Elasticsearch中添加映射会丢失分析器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码在Scala中。它非常类似于Java代码。

Code is in Scala. It is extremely similar to Java code.

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

Code that our map indexer uses to create index: https://gist.github.com/a16e5946b67c6d12b2b8

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

Utilities that the above code uses to create index and mapping: https://gist.github.com/4f88033204cd761abec0

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

Errors that java gives: https://gist.github.com/d6c835233e2b606a7074

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

Response of http://elasticsearch.domain/maps/_settings after running code and getting errors: https://gist.github.com/06ca7112ce1b01de3944

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

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

Attached are the json files i'm loading in. I have confirmed that it is loading the right json files and properly outputting it as a string into .loadFromSource and .setSource.

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

Any ideas why it can't find the analyzers even though they are in _settings? If I run these json files via curl they work fine and properly setup the mapping.

推荐答案

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

The code I was using to create the index (found here: Define custom ElasticSearch Analyzer using Java API) was creating settings in the index like:

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

"index.settings.analysis.filter.my_snow.type: "stemmer","

它在设置路径中有设置。

It had settings in the setting path.

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

I changed my indexing code to the following to fix this:

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

这篇关于使用java api创建索引并在Elasticsearch中添加映射会丢失分析器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆