opensearch-project / opensearch-project/opensearch-java

[BUG] MultiTermVectorsOperation requires optional fields

Open
#903 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
165
Forks
250
Avg merge
1d 18h
Merged PRs (30d)
26

Description

What is the bug?

The MultiTermVectorsOperation class has all fields listed as required (see the constructor where each has ApiTypeHelper.requireNonNull or ApiTypeHelper.unmodifiableRequired) that according to the documentation should be optional. I used the documentation from ElasticSearch 7.10 as there is no documentation via OpenSearch that I could find.

Additionally, the version field is a boolean in the documentation but in the client API it is of type long.

https://www.elastic.co/guide/en/elasticsearch/reference/7.10/docs-multi-termvectors.html

How can one reproduce the bug?

Create a MtermvectorsRequest.Builder and add multiple MultiTermVectorsOperation objects to it. Either do not set an optional field like payloads or set both id and doc (as both are required) and the following errors are generated

When both id and doc are specified the following error occurs:

org.opensearch.client.opensearch._types.OpenSearchException: Request failed: [parse_exception] failed to parse term vectors request. either [id] or [doc] can be specified, but not both!
	at org.opensearch.client.transport.httpclient5.ApacheHttpClient5Transport.prepareResponse(ApacheHttpClient5Transport.java:503) ~[opensearch-java-2.8.1.jar:?]
	at org.opensearch.client.transport.httpclient5.ApacheHttpClient5Transport.lambda$performRequestAsync$0(ApacheHttpClient5Transport.java:178) ~[opensearch-java-2.8.1.jar:?]
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646) ~[?:?]
	at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510) ~[?:?]
	at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2179) ~[?:?]
	at org.opensearch.client.transport.httpclient5.ApacheHttpClient5Transport$1.completed(ApacheHttpClient5Transport.java:223) ~[opensearch-java-2.8.1.jar:?]
	at org.opensearch.client.transport.httpclient5.ApacheHttpClient5Transport$1.completed(ApacheHttpClient5Transport.java:212) ~[opensearch-java-2.8.1.jar:?]

If doc is removed, then the following error occurs:

org.opensearch.client.util.MissingRequiredPropertyException: Missing required property 'MultiTermVectorsOperation.doc'
	at org.opensearch.client.util.ApiTypeHelper.requireNonNull(ApiTypeHelper.java:89) ~[opensearch-java-2.8.1.jar:?]
	at org.opensearch.client.opensearch.core.mtermvectors.MultiTermVectorsOperation.<init>(MultiTermVectorsOperation.java:85) ~[opensearch-java-2.8.1.jar:?]
	at org.opensearch.client.opensearch.core.mtermvectors.MultiTermVectorsOperation$Builder.build(MultiTermVectorsOperation.java:420) ~[opensearch-java-2.8.1.jar:?]

if id is removed, then the following error occurs:

org.opensearch.client.util.MissingRequiredPropertyException: Missing required property 'MultiTermVectorsOperation.id'
	at org.opensearch.client.util.ApiTypeHelper.requireNonNull(ApiTypeHelper.java:89) ~[opensearch-java-2.8.1.jar:?]
	at org.opensearch.client.opensearch.core.mtermvectors.MultiTermVectorsOperation.<init>(MultiTermVectorsOperation.java:89) ~[opensearch-java-2.8.1.jar:?]
	at org.opensearch.client.opensearch.core.mtermvectors.MultiTermVectorsOperation$Builder.build(MultiTermVectorsOperation.java:420) ~[opensearch-java-2.8.1.jar:?]
What is the expected behavior?

I would expect to not be required to set optional fields or be able to specify either doc or id field and have the call succeed.

What is your host/environment?

Amazon OpenSearch Service version 2.11
Java client version 2.8.1

Do you have any screenshots?

I've included stack trace snippets above.

Do you have any additional context?

We are migrating from ElasticSearch 6.8 to OpenSearch 2.x and make use of the multiterm vector capability in our search application and this is a blocker.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the MultiTermVectorsOperation constructor and Builder.build path identified in the stack traces, then inspect how its fields are generated and validated. Compare the id, doc, payloads, and version definitions with the linked Elasticsearch documentation. Done means optional fields can be omitted, either id or doc can be used, and version has the documented type, with regression coverage for these cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.