opensearch-java icon indicating copy to clipboard operation
opensearch-java copied to clipboard

[BUG] Missing Required Property `Builder.<variant kind>`

Open slemly opened this issue 2 years ago • 2 comments

What is the bug?

When I attempt to make a openSearchClient.indices().get(indexRequest) call with a valid index that should return multiple results, I am met with a MissingRequiredPropertyException from the client.

This bug is nearly identical to the closed issue detailed here - https://github.com/elastic/elasticsearch-java/issues/249.

My setup is almost identical to the setup described in this forum post, the only difference being that my call is a .get() -

String index = "index_a*"; // imagine indexing pattern being 'index_a0, index_a1, index_b0' etc
List<String> indices = new ArrayList<>();
List<ExpandWildcard> wildcards = new ArrayList<>();
wildcards.add(ExpandWildcard.All);
indices.add(index);
GetIndexRequest request = new GetIndexRequest.Builder().expandWildCards(wildcards).index(indices).build();
GetIndexResponse response = openSearchClient.indices.get(request);   // <-- exception thrown here

However, this exception is NOT thrown when I do the following -

String index = "index_a*"; // imagine indexing pattern being 'index_a0, index_a1, index_b0' etc
List<String> indices = new ArrayList<>();
List<ExpandWildcard> wildcards = new ArrayList<>();
wildcards.add(ExpandWildcard.All);
indices.add(index);
GetIndexRequest request = new GetIndexRequest.Builder().expandWildCards(wildcards).index(indices).build();
ApiTypeHelper.DANGEROUS_disableRequiredPropertiesCheck(true);
GetIndexResponse response = openSearchClient.indices.get(request);   // <--no exception thrown here
ApiTypeHelper.DANGEROUS_disableRequiredPropertiesCheck(false);

When this is executed, I receive the expected results of the query. This workaround was recommended by ElasticSearch documentation here.

I suspect that whichever version of the elastic client that operates under the hood in the version I am using (2.6.0) needs to be updated.

How can one reproduce the bug?

I am unsure how to reproduce this consistently, as it is intermittent in occurrence. I have also had it happen with a .index() call on the client, but that went away as I continued to work and I could not get it to be reproduced.

What is the expected behavior?

I expected to see two viable indexes returned in the response to my query.

What is your host/environment?

Mac OS Ventura 3.4.1 OpenSearch Java Client 2.6.0 Java 11 Connected to AWS as described here; can insert indexes and documents without issue

slemly avatar Aug 29 '23 03:08 slemly

Let's leave Elastic aside. It's likely the same bug. Feel free to turn it into a failing unit/integration test and make a PR with a fix. Please make sure not to look at any non-open source code.

dblock avatar Aug 29 '23 21:08 dblock

Let's leave Elastic aside. It's likely the same bug. Feel free to turn it into a failing unit/integration test and make a PR with a fix. Please make sure not to look at any non-open source code.

Sounds good - was not aware they changed their licensing, and will be sure to avoid non-OSS code in my solution. Will work on crafting a fix and a test.

slemly avatar Sep 22 '23 00:09 slemly