spring-data-elasticsearch,Mapping,spring Data Elasticsearch" /> spring-data-elasticsearch,Mapping,spring Data Elasticsearch" />

Mapping 使用spring数据elasticsearch,如何更新字段映射?

Mapping 使用spring数据elasticsearch,如何更新字段映射?,mapping,spring-data-elasticsearch,Mapping,spring Data Elasticsearch,我正在使用spring data elasticsearch 2.1.4.RELEASE,如何使用ElasticsearchOperations更新类型的字段映射 当我尝试operations.putMapping(EsJob.class)时;同样,也有例外: 因为createdBy字段已经存在,但我想更新它。 有谁有更好的解决方案吗 Servlet.service() for servlet [dispatcher] in context with path [/api] threw exce

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

当我尝试operations.putMapping(EsJob.class)时;同样,也有例外: 因为createdBy字段已经存在,但我想更新它。 有谁有更好的解决方案吗

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)

通常不能更新现有索引上的映射。这就是为什么
ElasticsearchOperations
-接口也不提供此功能的原因

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

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