首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >使用spring-data-elasticsearch,如何更新字段映射?

使用spring-data-elasticsearch,如何更新字段映射?
EN

Stack Overflow用户
提问于 2017-07-12 06:54:50
回答 1查看 2.4K关注 0票数 2

我正在使用spring-data-elasticsearch 2.1.4.RELEASE,如何使用ElasticsearchOperations更新类型的字段映射?

当我再次尝试operations.putMapping(EsJob.class);时,出现了异常:因为字段createdBy已经存在,但我想要更新它。有人有更好的解决方案吗?

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
Servlet.service() for servlet [dispatcher] in context with path [/api] threw exception [Request processing failed; nested exception is java.lang.IllegalgumentException: Mapper for [createdBy] conflicts with existing mapping in other types:
[mapper [createdBy] has different [store] values, mapper [createdBy] has different [analyzer]]] with root cause
java.lang.IllegalArgumentException: Mapper for [createdBy] conflicts with existing mapping in other types:
[mapper [createdBy] has different [store] values, mapper [createdBy] has different [analyzer]]
        at org.elasticsearch.index.mapper.FieldTypeLookup.checkCompatibility(FieldTypeLookup.java:153)
        at org.elasticsearch.index.mapper.FieldTypeLookup.copyAndAddAll(FieldTypeLookup.java:115)
        at org.elasticsearch.index.mapper.MapperService.merge(MapperService.java:381)
        at org.elasticsearch.index.mapper.MapperService.merge(MapperService.java:320)
        at org.elasticsearch.cluster.metadata.MetaDataMappingService$PutMappingExecutor.applyRequest(MetaDataMappingService.java:306)
        at org.elasticsearch.cluster.metadata.MetaDataMappingService$PutMappingExecutor.execute(MetaDataMappingService.java:230)
        at org.elasticsearch.cluster.service.InternalClusterService.runTasksForExecutor(InternalClusterService.java:468)
        at org.elasticsearch.cluster.service.InternalClusterService$UpdateTask.run(InternalClusterService.java:772)
        at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedEsThreadPoolExecutor.java:231)
        at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:194)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:748)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-07-12 07:22:59

一般来说,您不能更新现有索引上的映射。这就是为什么ElasticsearchOperations-Interface不提供此功能的原因。

您可以为新索引应用新映射或在现有映射中添加新字段,也可以通过删除索引来删除映射。根据这一点,当将另一个映射放入更新现有映射时,您会收到一个错误。

如果需要进行重大更改,则必须使用此新映射重新索引数据。有关在不停机的情况下执行此操作的信息,请参阅此post

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45050478

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文