2017-07-12 5 views
0

私は、spring-data-elasticsearchを使用しています。2.1.4.RELEASE、ElasticsearchOperationsを使用してタイプのフィールドマッピングを更新するにはどうすればよいですか?spring-data-elasticsearchを使用して、フィールドマッピングを更新するにはどうすればよいですか?

私は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) 

答えて

0

一般的に既存のインデックスのマッピングを更新することはできません。そのため、これもElasticsearchOperations -Interfaceでは提供されていません。

新しいインデックスに新しいマッピングを適用したり、新しいフィールドを既存のマッピングに追加したり、インデックスを削除してマッピングを削除したりすることができます。これによると、別のマッピングを既存のものを更新するために配置するときにエラーが発生します。

大きな変更が必要な場合は、この新しいマッピングでデータを再インデックスする必要があります。これをダウンタイムなしに行うには、postを参照してください。

関連する問題