Hi everyone,
I would appreciate any help with the following issue (workaround, bug confirmation etc.). Thanks!
I cannot use the java client to create an index with a mapping for a flat_object property. I am using the latest client (opensearch-java: 2.8.0) and server code (OpenSearch server: 2.11.0). I tried the following simple code:
final CreateIndexRequest createIndexRequest
= new CreateIndexRequest.Builder()
.index("sample_index")
.mappings(m -> m.properties("sample_property", Property.of(p -> p.flattened(new FlattenedProperty.Builder().build()))))
.build();
final CreateIndexResponse createIndexResponse
= client.indices().create(createIndexRequest);
which results in the following error:
org.opensearch.client.opensearch._types.OpenSearchException: Request failed: [mapper_parsing_exception] Failed to parse mapping [_doc]: No handler for type [flattened] declared on field [sample_property]
Interestingly, the Java client (and generated JSON payload) use the name ‘flattened’ for the field type, which is the ElasticSearch name for its version of the flat_object field type (Flattened field type | Elasticsearch Guide [8.11] | Elastic). If I execute the corresponding REST command in Dashboards and change the field type from ‘flattened’ to ‘flat_object’, it works (though the autocomplete does not suggest ‘flat_object’, as it does for other field types):
PUT /sample_index
{
"mappings" : {
"properties" : {
"sample_property" : {
"type" : "flat_object"
}
}
}
}
I think this is a bug in the client. Unfortunately, I have not been able to find a workaround in the Java client which allows me to replace ‘flattened’ with ‘flat_object’.