ElasticSearch 出现 ClassCastException – 将 MappingMetadata 转换为 MappingMetadata。

huangapple go评论75阅读模式
英文:

ElasticSearch ClassCastException - MappingMetadata to MappingMetadata

问题

以下是翻译好的部分:

我需要你的帮助。我不知道这里出了什么问题。

当我启动我的JavaApp从ElasticSearch获取数据时,我遇到了这个ClassCastException:

ElasticDBPersistanceImp | findQueryField failed for templateId
java.lang.ClassCastException: org.elasticsearch.cluster.metadata.MappingMetadata cannot be cast to org.elasticsearch.cluster.metadata.MappingMetaData
	at com.initka.bprocess.hforms_formlist.persistance.impl.elastic.ElasticDBPersistanceImpl.getAllFields(ElasticDBPersistanceImpl.java:251) ~[classes/:?]
	at com.initka.bprocess.hforms_formlist.persistance.impl.elastic.ElasticDBPersistanceImpl.findQueryField(ElasticDBPersistanceImpl.java:226) ~[classes/:?]
	at com.initka.bprocess.hforms_formlist.persistance.impl.elastic.ElasticDBPersistanceImpl.getFieldDataDistict(ElasticDBPersistanceImpl.java:163) ~[classes/:?]
	at com.initka.bprocess.hforms_formlist.startup.FormListSecurityServiceImpl.getTemplateIds(FormListSecurityServiceImpl.java:40) ~[classes/:?]
	at com.initka.bprocess.hforms_formlist.startup.FormListSecurityServiceImpl.<init>(FormListSecurityServiceImpl.java:21) ~[classes/:?]
	at com.initka.bprocess.hforms_formlist.startup.HformsFormlistFactoryImpl.<init>(HformsFormlistFactoryImpl.java:55) ~[classes/:?]
	at com.initka.bprocess.hforms_formlist.startup.Booter.startTenant(Booter.java:70) ~[classes/:?]
	at com.initka.bprocess.hforms_formlist.startup.Booter.lambda$0(Booter.java:45) ~[classes/:?]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]

我正在使用的代码在这里提供:https://www.elastic.co/guide/en/elasticsearch/client/java-rest/master/java-rest-high-get-mappings.html

所以稍微修改一下,它看起来像这样:

GetMappingsResponse mapping1 = dbManager.getFormlistDBConnection().indices().getMapping(getMappingsRequest, RequestOptions.DEFAULT);
Map<String, MappingMetaData> mappings2 = mapping1.mappings();
MappingMetaData mappingMetaData = mappings2.get(indexName);
Map<String, Object> sourceAsMap = mappingMetaData.getSourceAsMap();

所以也许你们中的某些人知道这里出了什么问题吗?

提前感谢。

英文:

I need your help. I haven't any idea whats wrong here.

When I start my JavaApp to get Data from ElasticSearch I get this ClassCastException:

ElasticDBPersistanceImp | findQueryField failed for templateId
java.lang.ClassCastException: org.elasticsearch.cluster.metadata.MappingMetadata cannot be cast to org.elasticsearch.cluster.metadata.MappingMetaData
	at com.initka.bprocess.hforms_formlist.persistance.impl.elastic.ElasticDBPersistanceImpl.getAllFields(ElasticDBPersistanceImpl.java:251) ~[classes/:?]
	at com.initka.bprocess.hforms_formlist.persistance.impl.elastic.ElasticDBPersistanceImpl.findQueryField(ElasticDBPersistanceImpl.java:226) ~[classes/:?]
	at com.initka.bprocess.hforms_formlist.persistance.impl.elastic.ElasticDBPersistanceImpl.getFieldDataDistict(ElasticDBPersistanceImpl.java:163) ~[classes/:?]
	at com.initka.bprocess.hforms_formlist.startup.FormListSecurityServiceImpl.getTemplateIds(FormListSecurityServiceImpl.java:40) ~[classes/:?]
	at com.initka.bprocess.hforms_formlist.startup.FormListSecurityServiceImpl.&lt;init&gt;(FormListSecurityServiceImpl.java:21) ~[classes/:?]
	at com.initka.bprocess.hforms_formlist.startup.HformsFormlistFactoryImpl.&lt;init&gt;(HformsFormlistFactoryImpl.java:55) ~[classes/:?]
	at com.initka.bprocess.hforms_formlist.startup.Booter.startTenant(Booter.java:70) ~[classes/:?]
	at com.initka.bprocess.hforms_formlist.startup.Booter.lambda$0(Booter.java:45) ~[classes/:?]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]

The code I'm using is provided at the Docs here https://www.elastic.co/guide/en/elasticsearch/client/java-rest/master/java-rest-high-get-mappings.html

So with a little bit of modification it looks like:

GetMappingsResponse mapping1 = dbManager.getFormlistDBConnection().indices().getMapping(getMappingsRequest, RequestOptions.DEFAULT);
    Map&lt;String, MappingMetaData&gt; mappings2 = mapping1.mappings();
    MappingMetaData mappingMetaData = mappings2.get(indexName);
    Map&lt;String, Object&gt; sourceAsMap = mappingMetaData.getSourceAsMap();

So maybe someone of you has an Idea whats wrong here?

Thanks in advance

答案1

得分: 0

经过几个小时的搜索,似乎是Maven的缓存问题。

在删除了本地Maven仓库并重新加载资源之后,现在似乎可以正常工作了。

英文:

After hours of searching it seems that it was a chaching problem with maven.

After deleting my local maven repo an reload the sources it seems to work now.

huangapple
  • 本文由 发表于 2020年8月27日 14:35:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/63610416.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定