elastic / elasticsearch-java

Official Elasticsearch Java Client
Apache License 2.0
408 stars 237 forks source link

Allow custom SpanQuery #780

Closed stures closed 4 months ago

stures commented 4 months ago

Description

Java API client version 8.13 Java version 21 Elasticsearch Version 8.13

In the Query class we can implement our own query types using Kind._Custom and _customKind

This allows us to make extension functions such as:

fun Query.Builder.CustomQuery(fn: Function<CustomQuery.Builder, ObjectBuilder<CustomQuery>>): ObjectBuilder<Query> {
   return this._custom("custom_query", fn.apply(CustomQuery.Builder()).build())
}

These options are missing in the corresponding enum for the SpanQuery class so there seems to be no way to add new query types that work within Spans.

We would like the same option here, it seems like all that is missing is the same option in the enum and corresponding additions to the Deserializer, but I guess we can't make a PR since the code is generated.

Is it possible to use this generator ourselves to generate a custom version of the java client?

swallez commented 4 months ago

This is an issue in the API specification that is used to generate the code, where SpanQuery wasn't labelled as extensible, like the general queries are. This will be fixed in https://github.com/elastic/elasticsearch-specification/pull/2509 and then in the next patch release of the Java client.

Thanks for reporting it.

stures commented 4 months ago

Great to hear! Thank you!

l-trotta commented 4 months ago

fixed in 8.13.3