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

java.lang.IllegalStateException: Cannot get 'BoxPlot' variant: current variant is '_Custom'. #558

Closed
marc- opened this issue Apr 20, 2023 · 3 comments · Fixed by #824
Closed
Labels
Area: Specification Related to the API spec used to generate client code Category: Bug Something isn't working

Comments

@marc-
Copy link

marc- commented Apr 20, 2023

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)
@l-trotta
Copy link
Contributor

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!

marc- added a commit to marc-/elasticsearch-java that referenced this issue Mar 28, 2024
Signed-off-by: Maksim Chizhov <[email protected]>
@marc-
Copy link
Author

marc- commented Mar 28, 2024

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 marc-@330ea46 .

@l-trotta
Copy link
Contributor

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!

@l-trotta l-trotta added Area: Specification Related to the API spec used to generate client code Category: Bug Something isn't working labels May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Specification Related to the API spec used to generate client code Category: Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants