elasticsearch-net
elasticsearch-net copied to clipboard
Put mapping results in 400
Elastic.Clients.Elasticsearch version: Elastic.Clients.Elasticsearch 8.11.0
Elasticsearch version: 8.11.1
.NET runtime version: 8.0.100
Operating system version: Windows 10
Description of the problem including expected versus actual behavior:
I am trying to update a dynamic template using the elastic-search-client in version 8 and being provided with a 400 error. Setting the same dynamic-template
via the create index works flawlessly.
Steps to reproduce:
var response = await _client.Indices.PutMappingAsync<DocumentT>(index, c => c
.DynamicTemplates(new List<IDictionary<string, DynamicTemplate>>
{
new Dictionary<string, DynamicTemplate>
{
{ "my-template", new DynamicTemplate
{
MatchMappingType = "string",
Mapping = new TextProperty
{
Analyzer = "iq_text_base",
Fields = new Properties
{
{
"date", new DateProperty
{
Format = "strict_date_time||strict_date",
IgnoreMalformed = true
}
}
},
IndexOptions = IndexOptions.Freqs,
}
}
}
}
}), ct);
Expected behavior The client should send the request in an acceptable format.
**Provide DebugInformation
**:
Invalid Elasticsearch response built from a unsuccessful (400) low level call on PUT: /search-sportworld-events/_mapping?pretty=true&error_trace=true
Exception: Request failed to execute. Call: Status code 400 from: PUT /search-sportworld-events/_mapping?pretty=true&error_trace=true. ServerError: Type: mapper_parsing_exception Reason: "Failed to parse mapping: Dynamic template syntax error. An array of named objects is expected." CausedBy: "Type: mapper_parsing_exception Reason: "Dynamic template syntax error. An array of named objects is expected.""
# Audit trail of this API call:
- [1] BadResponse: Node: https://b1-sportworld-dev-eu-central-1.es.eu-central-1.aws.cloud.es.io/ Took: 00:00:00.0682161
# OriginalException: Elastic.Transport.TransportException: Request failed to execute. Call: Status code 400 from: PUT /search-sportworld-events/_mapping?pretty=true&error_trace=true. ServerError: Type: mapper_parsing_exception Reason: "Failed to parse mapping: Dynamic template syntax error. An array of named objects is expected." CausedBy: "Type: mapper_parsing_exception Reason: "Dynamic template syntax error. An array of named objects is expected.""
# Request:
{
"dynamic_templates": {
"my-template": {
"mapping": {
"analyzer": "iq_text_base",
"fields": {
"date": {
"format": "strict_date_time||strict_date",
"ignore_malformed": true,
"type": "date"
}
},
"index_options": "freqs",
"type": "text"
},
"match_mapping_type": "string"
}
}
}
# Response:
{
"error" : {
"root_cause" : [
{
"type" : "mapper_parsing_exception",
"reason" : "Dynamic template syntax error. An array of named objects is expected.",
"stack_trace" : "org.elasticsearch.index.mapper.MapperParsingException: Dynamic template syntax error. An array of named objects is expected.\n\tat [email protected]/org.elasticsearch.index.mapper.RootObjectMapper.processField(RootObjectMapper.java:455)\n\tat [email protected]/org.elasticsearch.index.mapper.RootObjectMapper.parse(RootObjectMapper.java:412)\n\tat [email protected]/org.elasticsearch.index.mapper.MappingParser.parse(MappingParser.java:116)\n\tat [email protected]/org.elasticsearch.index.mapper.MappingParser.parse(MappingParser.java:83)\n\tat [email protected]/org.elasticsearch.index.mapper.MapperService.parseMapping(MapperService.java:538)\n\tat [email protected]/org.elasticsearch.cluster.metadata.MetadataMappingService$PutMappingExecutor.applyRequest(MetadataMappingService.java:150)\n\tat [email protected]/org.elasticsearch.cluster.metadata.MetadataMappingService$PutMappingExecutor.execute(MetadataMappingService.java:115)\n\tat [email protected]/org.elasticsearch.cluster.service.MasterService.innerExecuteTasks(MasterService.java:1039)\n\tat [email protected]/org.elasticsearch.cluster.service.MasterService.executeTasks(MasterService.java:1004)\n\tat [email protected]/org.elasticsearch.cluster.service.MasterService.executeAndPublishBatch(MasterService.java:232)\n\tat [email protected]/org.elasticsearch.cluster.service.MasterService$BatchingTaskQueue$Processor.lambda$run$2(MasterService.java:1626)\n\tat [email protected]/org.elasticsearch.action.ActionListener.run(ActionListener.java:368)\n\tat [email protected]/org.elasticsearch.cluster.service.MasterService$BatchingTaskQueue$Processor.run(MasterService.java:1623)\n\tat [email protected]/org.elasticsearch.cluster.service.MasterService$5.lambda$doRun$0(MasterService.java:1237)\n\tat [email protected]/org.elasticsearch.action.ActionListener.run(ActionListener.java:368)\n\tat [email protected]/org.elasticsearch.cluster.service.MasterService$5.doRun(MasterService.java:1216)\n\tat [email protected]/org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:983)\n\tat [email protected]/org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)\n\tat java.base/java.lang.Thread.run(Thread.java:1583)\n"
}
],
"type" : "mapper_parsing_exception",
"reason" : "Failed to parse mapping: Dynamic template syntax error. An array of named objects is expected.",
"caused_by" : {
"type" : "mapper_parsing_exception",
"reason" : "Dynamic template syntax error. An array of named objects is expected.",
"stack_trace" : "org.elasticsearch.index.mapper.MapperParsingException: Dynamic template syntax error. An array of named objects is expected.\n\tat [email protected]/org.elasticsearch.index.mapper.RootObjectMapper.processField(RootObjectMapper.java:455)\n\tat [email protected]/org.elasticsearch.index.mapper.RootObjectMapper.parse(RootObjectMapper.java:412)\n\tat [email protected]/org.elasticsearch.index.mapper.MappingParser.parse(MappingParser.java:116)\n\tat [email protected]/org.elasticsearch.index.mapper.MappingParser.parse(MappingParser.java:83)\n\tat [email protected]/org.elasticsearch.index.mapper.MapperService.parseMapping(MapperService.java:538)\n\tat [email protected]/org.elasticsearch.cluster.metadata.MetadataMappingService$PutMappingExecutor.applyRequest(MetadataMappingService.java:150)\n\tat [email protected]/org.elasticsearch.cluster.metadata.MetadataMappingService$PutMappingExecutor.execute(MetadataMappingService.java:115)\n\tat [email protected]/org.elasticsearch.cluster.service.MasterService.innerExecuteTasks(MasterService.java:1039)\n\tat [email protected]/org.elasticsearch.cluster.service.MasterService.executeTasks(MasterService.java:1004)\n\tat [email protected]/org.elasticsearch.cluster.service.MasterService.executeAndPublishBatch(MasterService.java:232)\n\tat [email protected]/org.elasticsearch.cluster.service.MasterService$BatchingTaskQueue$Processor.lambda$run$2(MasterService.java:1626)\n\tat [email protected]/org.elasticsearch.action.ActionListener.run(ActionListener.java:368)\n\tat [email protected]/org.elasticsearch.cluster.service.MasterService$BatchingTaskQueue$Processor.run(MasterService.java:1623)\n\tat [email protected]/org.elasticsearch.cluster.service.MasterService$5.lambda$doRun$0(MasterService.java:1237)\n\tat [email protected]/org.elasticsearch.action.ActionListener.run(ActionListener.java:368)\n\tat [email protected]/org.elasticsearch.cluster.service.MasterService$5.doRun(MasterService.java:1216)\n\tat [email protected]/org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:983)\n\tat [email protected]/org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)\n\tat java.base/java.lang.Thread.run(Thread.java:1583)\n"
},
"stack_trace" : "org.elasticsearch.index.mapper.MapperParsingException: Failed to parse mapping: Dynamic template syntax error. An array of named objects is expected.\n\tat [email protected]/org.elasticsearch.index.mapper.MapperService.parseMapping(MapperService.java:540)\n\tat [email protected]/org.elasticsearch.cluster.metadata.MetadataMappingService$PutMappingExecutor.applyRequest(MetadataMappingService.java:150)\n\tat [email protected]/org.elasticsearch.cluster.metadata.MetadataMappingService$PutMappingExecutor.execute(MetadataMappingService.java:115)\n\tat [email protected]/org.elasticsearch.cluster.service.MasterService.innerExecuteTasks(MasterService.java:1039)\n\tat [email protected]/org.elasticsearch.cluster.service.MasterService.executeTasks(MasterService.java:1004)\n\tat [email protected]/org.elasticsearch.cluster.service.MasterService.executeAndPublishBatch(MasterService.java:232)\n\tat [email protected]/org.elasticsearch.cluster.service.MasterService$BatchingTaskQueue$Processor.lambda$run$2(MasterService.java:1626)\n\tat [email protected]/org.elasticsearch.action.ActionListener.run(ActionListener.java:368)\n\tat [email protected]/org.elasticsearch.cluster.service.MasterService$BatchingTaskQueue$Processor.run(MasterService.java:1623)\n\tat [email protected]/org.elasticsearch.cluster.service.MasterService$5.lambda$doRun$0(MasterService.java:1237)\n\tat [email protected]/org.elasticsearch.action.ActionListener.run(ActionListener.java:368)\n\tat [email protected]/org.elasticsearch.cluster.service.MasterService$5.doRun(MasterService.java:1216)\n\tat [email protected]/org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:983)\n\tat [email protected]/org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)\n\tat java.base/java.lang.Thread.run(Thread.java:1583)\nCaused by: org.elasticsearch.index.mapper.MapperParsingException: Dynamic template syntax error. An array of named objects is expected.\n\tat [email protected]/org.elasticsearch.index.mapper.RootObjectMapper.processField(RootObjectMapper.java:455)\n\tat [email protected]/org.elasticsearch.index.mapper.RootObjectMapper.parse(RootObjectMapper.java:412)\n\tat [email protected]/org.elasticsearch.index.mapper.MappingParser.parse(MappingParser.java:116)\n\tat [email protected]/org.elasticsearch.index.mapper.MappingParser.parse(MappingParser.java:83)\n\tat [email protected]/org.elasticsearch.index.mapper.MapperService.parseMapping(MapperService.java:538)\n\t... 16 more\n"
},
"status" : 400
}
# TCP states:
Established: 137
TimeWait: 30
CloseWait: 1
# ThreadPool statistics:
Worker:
Busy: 1
Free: 32766
Min: 16
Max: 32767
IOCP:
Busy: 0
Free: 1000
Min: 1
Max: 1000