我正在尝试使用以下代码片段以编程方式在Elasticsearch中创建索引:
String indexName = "index";
String indexJson = createIndexJson();
elasticsearchTemplate.createIndex(indexName, indexJson);
createIndexJson()
返回以下字符串:
{
"mappings": {
"video": {
"properties": {
"title": {
"properties": {
"en": {
"type": "text",
"analyzer": "english"
}
}
},
"desc": {
"properties": {
"en": {
"type": "text",
"analyzer": "english"
}
}
}
}
}
}
}
elasticsearchTemplate
创建为:
new ElasticsearchTemplate(
new PreBuiltTransportClient(Settings.EMPTY)
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300)));
如果我运行此代码,我会收到以下异常:
java.lang.IllegalArgumentException: unknown setting [index.mappings.video.properties.desc.properties.en.analyzer] please check that any required plugins are installed, or check the breaking changes documentation for removed settings
at org.elasticsearch.common.settings.AbstractScopedSettings.validate(AbstractScopedSettings.java:346)
at org.elasticsearch.common.settings.AbstractScopedSettings.validate(AbstractScopedSettings.java:310)
at org.elasticsearch.common.settings.AbstractScopedSettings.validate(AbstractScopedSettings.java:284)
at org.elasticsearch.cluster.metadata.MetaDataCreateIndexService.onlyCreateIndex(MetaDataCreateIndexService.java:229)
at org.elasticsearch.cluster.metadata.MetaDataCreateIndexService.createIndex(MetaDataCreateIndexService.java:209)
at org.elasticsearch.action.admin.indices.create.TransportCreateIndexAction.masterOperation(TransportCreateIndexAction.java:81)
at org.elasticsearch.action.admin.indices.create.TransportCreateIndexAction.masterOperation(TransportCreateIndexAction.java:39)
at org.elasticsearch.action.support.master.TransportMasterNodeAction.masterOperation(TransportMasterNodeAction.java:88)
at org.elasticsearch.action.support.master.TransportMasterNodeAction$AsyncSingleAction$2.doRun(TransportMasterNodeAction.java:167)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
at org.elasticsearch.common.util.concurrent.EsExecutors$1.execute(EsExecutors.java:135)
at org.elasticsearch.action.support.master.TransportMasterNodeAction$AsyncSingleAction.doStart(TransportMasterNodeAction.java:164)
at org.elasticsearch.action.support.master.TransportMasterNodeAction$AsyncSingleAction.start(TransportMasterNodeAction.java:127)
at org.elasticsearch.action.support.master.TransportMasterNodeAction.doExecute(TransportMasterNodeAction.java:105)
at org.elasticsearch.action.support.master.TransportMasterNodeAction.doExecute(TransportMasterNodeAction.java:55)
at org.elasticsearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:167)
at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:139)
at org.elasticsearch.action.support.HandledTransportAction$TransportHandler.messageReceived(HandledTransportAction.java:79)
at org.elasticsearch.action.support.HandledTransportAction$TransportHandler.messageReceived(HandledTransportAction.java:69)
at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:66)
at org.elasticsearch.transport.TcpTransport$RequestHandler.doRun(TcpTransport.java:1555)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
at org.elasticsearch.common.util.concurrent.EsExecutors$1.execute(EsExecutors.java:135)
at org.elasticsearch.transport.TcpTransport.handleRequest(TcpTransport.java:1512)
at org.elasticsearch.transport.TcpTransport.messageReceived(TcpTransport.java:1382)
at org.elasticsearch.transport.netty4.Netty4MessageChannelHandler.channelRead(Netty4MessageChannelHandler.java:64)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:297)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:413)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.handler.logging.LoggingHandler.channelRead(LoggingHandler.java:241)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1359)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:935)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:134)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:545)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:499)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
at java.lang.Thread.run(Thread.java:748)
Suppressed: java.lang.IllegalArgumentException: unknown setting [index.mappings.video.properties.desc.properties.en.type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings
... 51 common frames omitted
Suppressed: java.lang.IllegalArgumentException: unknown setting [index.mappings.video.properties.title.properties.en.analyzer] please check that any required plugins are installed, or check the breaking changes documentation for removed settings
... 51 common frames omitted
Suppressed: java.lang.IllegalArgumentException: unknown setting [index.mappings.video.properties.title.properties.en.type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings
... 51 common frames omitted
所以基本上它抱怨索引定义的这一部分:
"en": {
"type": "text",
"analyzer": "english"
}
如果我使用相同的索引定义并使用它来使用Elasticsearch REST API PUT localhost:9200/index
创建索引,那么Elasticsearch 5.6.6和Elasticsearch 6.2.1都可以正常工作
我注意到,由于此代码请求不会转到Elasticsearch服务器,因此显然它们无法在客户端验证。
这种验证失败的原因是什么?我是否需要在Elasticsearch客户端配置中添加插件?