Easysearch、Elasticsearch 还是 Opensearch,是个问题

新建索引出现重复字段类型不同报错。。求助!!

Elasticsearch | 作者 zhengchar | 发布于2020年05月02日 | 阅读数:2920

版本:ES 7.6.0
背景:
集群中已有多个index template,其中包含自动mapping的模版,部分模版中声明了"timestamp"字段,类型为"date"。
现在集群中使用rest方式put新索引(索引名不会匹配任何现有索引模版的模式),请求如下:
{
  "settings": {
    "number_of_shards": 3,
    "number_of_replicas": 1,
    "refresh_interval": "30s"
  },
  "mappings": {
    "properties": {
      "test1": {
        "type": "keyword",
        "ignore_above": 512
      },
      "test2": {
        "type": "keyword",
        "ignore_above": 512
      },
      "timestamp": {
        "type": "long"
      }

    }
  }
}
创建索引时报错,stacktrace如下:
{ - 
        "type": "mapper_parsing_exception",
        "reason": "Mapping definition for [timestamp] has unsupported parameters: [format : strict_date_optional_time||epoch_millis]",
        "stack_trace": "MapperParsingException[Mapping definition for [timestamp] has unsupported parameters: [format : strict_date_optional_time||epoch_millis]]\n\tat org.elasticsearch.index.mapper.DocumentMapperParser.checkNoRemainingFields(DocumentMapperParser.java:148)\n\tat org.elasticsearch.index.mapper.DocumentMapperParser.checkNoRemainingFields(DocumentMapperParser.java:142)\n\tat org.elasticsearch.index.mapper.ObjectMapper$TypeParser.parseProperties(ObjectMapper.java:284)\n\tat org.elasticsearch.index.mapper.ObjectMapper$TypeParser.parseObjectOrDocumentTypeProperties(ObjectMapper.java:196)\n\tat org.elasticsearch.index.mapper.RootObjectMapper$TypeParser.parse(RootObjectMapper.java:130)\n\tat org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:108)\n\tat org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:88)\n\tat org.elasticsearch.index.mapper.MapperService.internalMerge(MapperService.java:409)\n\tat org.elasticsearch.index.mapper.MapperService.merge(MapperService.java:339)\n\tat org.elasticsearch.cluster.metadata.MetaDataCreateIndexService.updateIndexMappingsAndBuildSortOrder(MetaDataCreateIndexService.java:661)\n\tat org.elasticsearch.cluster.metadata.MetaDataCreateIndexService.applyCreateIndexRequest(MetaDataCreateIndexService.java:300)\n\tat org.elasticsearch.cluster.metadata.MetaDataCreateIndexService$1.execute(MetaDataCreateIndexService.java:245)\n\tat org.elasticsearch.cluster.ClusterStateUpdateTask.execute(ClusterStateUpdateTask.java:47)\n\tat org.elasticsearch.cluster.service.MasterService.executeTasks(MasterService.java:702)\n\tat org.elasticsearch.cluster.service.MasterService.calculateTaskOutputs(MasterService.java:324)\n\tat org.elasticsearch.cluster.service.MasterService.runTasks(MasterService.java:219)\n\tat org.elasticsearch.cluster.service.MasterService.access$000(MasterService.java:73)\n\tat org.elasticsearch.cluster.service.MasterService$Batcher.run(MasterService.java:151)\n\tat org.elasticsearch.cluster.service.TaskBatcher.runIfNotProcessed(TaskBatcher.java:150)\n\tat org.elasticsearch.cluster.service.TaskBatcher$BatchedTask.run(TaskBatcher.java:188)\n\tat org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:633)\n\tat org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedEsThreadPoolExecutor.java:252)\n\tat org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:215)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\n\tat java.lang.Thread.run(Thread.java:830)\n"
}
个人判断:
据错误堆栈来看应该是认为索引中的timestamp字段应为date字段,与现有索引中的配置保持一致。想请教各位高人,这个是全新索引且模式未匹配任何其他模版,为何也会受影响?
已邀请:

God_lockin

赞同来自: zhengchar

你可以直接试试直接
PUT ${index}/_doc/1
{
....some fields....
"timestamp": ${long value}
}
 
进去试试,如果新建出来的索引的timestamp字段是date型,说明你某个template生效了

zhengchar

赞同来自:

补充一点:
将mapping配置中"dynamic":false加入,同样报错,请教各位高人!感谢感谢!

要回复问题请先登录注册