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

Add ES|QL helpers #762

Merged
merged 2 commits into from
Mar 13, 2024
Merged

Add ES|QL helpers #762

merged 2 commits into from
Mar 13, 2024

Conversation

swallez
Copy link
Member

@swallez swallez commented Mar 13, 2024

Adds helpers for ES|QL.

The ES|QL result format is meant to be compact: it is composed of a metadata part giving field names and their types and a 2D array of values, which isn't easy to use in application code.

This PR provides adapters that convert the ES|QL JSON result format into higher level types that are easier to use. Two adapters are provided:

  • An ObjectsAdatper that combines field names and values from the array to build a collection of objects using JSON to object mapping
  • A ResultSetAdpater that provides an implementation of the well-known JDBC ResultSet. This is a cursor-based API where the application can inspect at runtime the type and names of the ES|QL results, and is therefore more suited for ad-hoc or dynamic queries where the result structure isn't known in advance.

Along with adapters, additional methods in ElasticsearchEsqlClient provide simple way to send queries using just a string and optional parameters when you don't need to specify additional request details.

@swallez swallez merged commit d1dfacd into main Mar 13, 2024
7 checks passed
@swallez swallez deleted the esql branch March 13, 2024 16:03
github-actions bot pushed a commit that referenced this pull request Mar 13, 2024
Adds helpers for ES|QL.

The ES|QL result format is meant to be compact: it is composed of a metadata part giving field names and their types and a 2D array of values, which isn't easy to use in application code.

This PR provides adapters that convert the ES|QL JSON result format into higher level types that are easier to use. Two adapters are provided:
* An `ObjectsAdatper` that combines field names and values from the array to build a collection of objects using JSON to object mapping
* A `ResultSetAdpater` that provides an implementation of the well-known JDBC `ResultSet`. This is a cursor-based API where the application can inspect at runtime the type and names of the ES|QL results, and is therefore more suited for ad-hoc or dynamic queries where the result structure isn't known in advance.

Along with adapters, additional methods in `ElasticsearchEsqlClient` provide simple way to send queries using just a string and optional parameters when you don't need to specify additional request details.
swallez added a commit that referenced this pull request Mar 13, 2024
Adds helpers for ES|QL.

The ES|QL result format is meant to be compact: it is composed of a metadata part giving field names and their types and a 2D array of values, which isn't easy to use in application code.

This PR provides adapters that convert the ES|QL JSON result format into higher level types that are easier to use. Two adapters are provided:
* An `ObjectsAdatper` that combines field names and values from the array to build a collection of objects using JSON to object mapping
* A `ResultSetAdpater` that provides an implementation of the well-known JDBC `ResultSet`. This is a cursor-based API where the application can inspect at runtime the type and names of the ES|QL results, and is therefore more suited for ad-hoc or dynamic queries where the result structure isn't known in advance.

Along with adapters, additional methods in `ElasticsearchEsqlClient` provide simple way to send queries using just a string and optional parameters when you don't need to specify additional request details.

Co-authored-by: Sylvain Wallez <sylvain@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant