Closed
Description
Elastic.Clients.Elasticsearch version: 8.13.15
Elasticsearch version: 8.6.2
.NET runtime version: 8
Operating system version: Windows 11
Description of the problem including expected versus actual behavior:
Retrieving the mapping of an icu_collation_keyword
field and recreating it on another index results in it being created as object
Steps to reproduce:
- Create index using following mapping through kibana:
PUT /test-index
{
"settings": {},
"mappings": {
"properties": {
"icu_field": {
"language": "de",
"numeric": true,
"strength": "primary",
"type": "icu_collation_keyword",
"variant": "@collation=standard"
},
"multi_field": {
"fields": {
"sort": {
"numeric": true,
"strength": "primary",
"type": "icu_collation_keyword",
"variant": "@collation=standard"
},
"text": {
"type": "text"
}
},
"type": "keyword"
}
}
}
}
- Run repro:
using Elastic.Clients.Elasticsearch;
using Elastic.Clients.Elasticsearch.IndexManagement;
var index = "test-index";
var settings = new ElasticsearchClientSettings(new Uri("http://localhost:9200/"));
settings.DisableDirectStreaming();
var client = new ElasticsearchClient(settings);
var response = await client.Indices.GetAsync(index);
var sourceIndex = response.Indices.Single().Value;
var targetIndexSettings = new IndexSettings
{
NumberOfShards = 1,
NumberOfReplicas = 0
};
targetIndexSettings.Index ??= new IndexSettings();
targetIndexSettings.Index.Analysis = sourceIndex.Settings?.Index?.Analysis;
targetIndexSettings.Index.MaxNgramDiff = sourceIndex.Settings?.Index?.MaxNgramDiff;
var createIndexRequest = new CreateIndexRequest(index + "-cloned")
{
Mappings = sourceIndex.Mappings,
Settings = targetIndexSettings
};
var createResponse = await client.Indices.CreateAsync(createIndexRequest);
if (!createResponse.Acknowledged)
{
// throws
throw new Exception(createResponse.DebugInformation);
}
Expected behavior
Expected cloned index to be the same as source index
Provide DebugInformation
(if relevant):
Request failed to execute. Call: Status code 400 from: PUT /test-index-cloned. ServerError: Type: mapper_parsing_exception Reason: "Failed to parse mapping: Type [object] cannot be used in multi field" CausedBy: "Type: mapper_parsing_exception Reason: "Type [object] cannot be used in multi field""
# Audit trail of this API call:
- [1] BadResponse: Node: http://localhost:9200/ Took: 00:00:00.0281875
# OriginalException: Elastic.Transport.TransportException: Request failed to execute. Call: Status code 400 from: PUT /test-index-cloned. ServerError: Type: mapper_parsing_exception Reason: "Failed to parse mapping: Type [object] cannot be used in multi field" CausedBy: "Type: mapper_parsing_exception Reason: "Type [object] cannot be used in multi field""
# Request:
{"mappings":{"properties":{"icu_field":{"type":"object"},"multi_field":{"fields":{"sort":{"type":"object"},"text":{"type":"text"}},"type":"keyword"}}},"settings":{"index":{},"number_of_replicas":0,"number_of_shards":1}}
# Response:
{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Type [object] cannot be used in multi field"}],"type":"mapper_parsing_exception","reason":"Failed to parse mapping: Type [object] cannot be used in multi field","caused_by":{"type":"mapper_parsing_exception","reason":"Type [object] cannot be used in multi field"}},"status":400}