Skip to content

[FEATURE PROPOSAL] Allow to customize the mapped type for @InnerField and @Field annotations #2942

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

Closed
reta opened this issue Jul 18, 2024 · 2 comments · Fixed by #2950
Closed
Labels
type: enhancement A general enhancement

Comments

@reta
Copy link
Contributor

reta commented Jul 18, 2024

In Spring Data OpenSearch [1], which is built on top of Spring Data Elasticsearch, we are running into cases where both projects differ in incompatible ways. One of such cases is supported mapping field types (baked by org.springframework.data.elasticsearch.annotations.FieldType), for example:

Flattened("flattened"), //

would have to become

Flat_Object("flat_oblect"), //

for OpenSearch.

One of the simplest (but no necessarily good) ways to support Elasticsearch and OpenSearch is to maintain the union of both (Flattened and Flat_Object): solves the problem but adds confusion.

One of (arguably) better alternatives is to add optional mappedName attribute to @InnerField and @Field annotations (and model classes respectively), to address the possible divergence, for example:

@Field(type = FieldType.Flattened, mappedName = "flat_oblect") String flattenedField;

It would require a bit more work for OpenSearch users but not the Elasticsearch ones. The change would be non-breaking (defaults to "" and FieldType::getMappedType) and work seamlessly.

@sothawo I am wondering if you (or/and other maintainers) would be open to accept such feature proposal (I will be taking care of all the necessary work if greenlighted).

Thank you!

[1] https://github.com/opensearch-project/spring-data-opensearch

@sothawo
Copy link
Collaborator

sothawo commented Jul 19, 2024

Hi, sure, provide a PR for this.

@reta
Copy link
Contributor Author

reta commented Jul 19, 2024

(just for the record, it is just a coincidence but I am off next week, will pick this issue once back)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
3 participants