Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Support flat_object field type in Java client #720

Closed
jicohen opened this issue Nov 8, 2023 · 2 comments
Closed

[FEATURE] Support flat_object field type in Java client #720

jicohen opened this issue Nov 8, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@jicohen
Copy link

jicohen commented Nov 8, 2023

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" } } } }

@jicohen jicohen added enhancement New feature or request untriaged labels Nov 8, 2023
@Bfindlay
Copy link
Contributor

This doesn't seem to bad. I'll see if I get time to take a look over this week.

@Bfindlay
Copy link
Contributor

@takeitagain I have raised a PR #735
you will have to atleast use OpenSearch version 2.7.0 to use flat objects as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants