[FEATURE] Add support for Derived Fields
OpenSearch 2.15 introduced derived field types, but the opensearch-java client doesn't yet provide a way to use this feature.
Currently, both the SearchRequest and TypeMapping classes lack methods for setting derived fields. This creates an API mismatch where functionality available in the OpenSearch server isn't accessible through the official Java client.
It would be beneficial to have type-safe methods for working with derived fields in the Java client. Specifically:
- Methods to define derived fields in index mappings via TypeMapping
- Methods to set derived fields in search requests via SearchRequest
- Proper support in the client that matches the server's capabilities for derived fields
This would improve the developer experience and provide better consistency between the server and client APIs.
In earlier versions of the client, the runtimeMappings() method was available for similar functionality, but this approach doesn't work with derived fields and results in errors. Without any dedicated API for derived fields, the only working alternative is to use low-level JSON queries instead of the type-safe Java client API, which isn't ideal for maintainability.
See also: Forum discussion about this topic
Hi @andrross @cwperks ! Would it be okay if I try to implement this feature? If yes, are there any specific guidelines or considerations I should be aware of before starting? Thanks!
@ivamly certainly, any help across any repo in the OpenSearch-project is welcomed. Unfortunately, I have not contributed much to the clients and don't know how much help I can be. Perhaps @reta would be able to give some insight and how best to get started with this issue?
Thanks @cwperks , @ivamly we need https://github.com/opensearch-project/opensearch-api-specification/pull/976 to be merged first, so the schemas for code generation become available