-
Notifications
You must be signed in to change notification settings - Fork 222
[FEATURE] Support flat_object field type in Java client #720
Description
Is your feature request related to a problem?
The OpenSearch Java client does not support OpenSearch's 'flat_object' field type. Strangely it does support the 'flattened' field type (which is ElasticSearch's nomenclature, but not supported by the OpenSearch server). The following code causes an error to be returned by the OpenSearch server:
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);
response from server:
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]
What solution would you like?
Add support to the Java client for the 'flat_object' field type. You should be able to write code that looks something like this:
final CreateIndexRequest createIndexRequest = new CreateIndexRequest.Builder() .index("sample_index") .mappings(m -> m.properties("sample_property", Property.of(p -> p.flatObject(new FlatObject.Builder().build())))) .build(); final CreateIndexResponse createIndexResponse = client.indices().create(createIndexRequest);
which results in the following REST call to the server:
PUT /sample_index { "mappings" : { "properties" : { "sample_property" : { "type" : "flat_object" } } } }