elasticsearch-java
elasticsearch-java copied to clipboard
java.lang.IllegalStateException: Cannot get 'BoxPlot' variant: current variant is '_Custom'.
Java API client version
8.6.2,8.7.0
Java version
17
Elasticsearch Version
8.6.2
Problem description
BoxPlotAggregate
aggregation can no be extracted supposedly due to typo in Aggregate.java (comparing to Aggregation.java -- box_plot
vs boxplot
).
java.lang.IllegalStateException: Cannot get 'BoxPlot' variant: current variant is '_Custom'.
at co.elastic.clients.util.TaggedUnionUtils.get(TaggedUnionUtils.java:34)
at co.elastic.clients.elasticsearch._types.aggregations.Aggregate.boxPlot(Aggregate.java:331)
Hello and thank you for the report. I tried to reproduce this using the current version of the java client and it seems to be working, could you let me know if this is still an issue for you, and provide an example of the code used if that's the case? Thank you!
I can reproduce the issue with the latest client release (client 8.13.0, ES version 8.9.0). Sample request:
POST index/_search?typed_keys=true
{
"aggregations": {
"ed_stats": {
"boxplot": {
"field": "event.duration",
"compression": 300
}
}
}
}
response:
{
"_shards" : {
"failed" : 0,
"skipped" : 976,
"successful" : 980,
"total" : 980
},
"aggregations" : {
"boxplot#ed_stats" : {
"lower" : 16,
"max" : 60058,
"min" : 16,
"q1" : 246,
"q2" : 1010,
"q3" : 30212,
"upper" : 60058
}
},
"hits" : {
"hits" : [],
"max_score" : null,
"total" : {
"relation" : "eq",
"value" : 69
}
},
"timed_out" : false,
"took" : 455
}
Test to reproduce https://github.com/marc-/elasticsearch-java/commit/330ea469106e27d7a66e0871b2332cc6e57cad85 .
So, I tried the same request using the java client:
esClient.search(s -> s
.index("test")
.size(0)
.aggregations("box", ag -> ag.boxplot(bx -> bx
.field("year")
.compression(300d)))
, Object.class);
and the response seems to be extracted correctly. Not sure though why it's not working from the json, I'll investigate this further! Thank you for the quick reply and the reproducer!