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

mtermvectors with artificial documents not possible #716

Closed
oli-tu opened this issue Dec 1, 2023 · 0 comments · Fixed by #824
Closed

mtermvectors with artificial documents not possible #716

oli-tu opened this issue Dec 1, 2023 · 0 comments · Fixed by #824
Labels
Area: Specification Related to the API spec used to generate client code

Comments

@oli-tu
Copy link

oli-tu commented Dec 1, 2023

Java API client version

8.11.1

Java version

17

Elasticsearch Version

8.4.3

Problem description

The Multi term vectors API supports requests with artificial documents.

POST /_mtermvectors
{
  "docs": [
    {
      "_index": "myIndex",
      "doc": {
        "foo" : "bar"
      }
    }
  ]
}

This is not possible, as the Java client requires an _id within the document:

String artificialDoc = String.format("{\"%s\": \"%s\"}", "foo", "bar");
JsonData jsonData = JsonData.fromJson(artificialDoc);
MtermvectorsRequest request = MtermvectorsRequest.of(b -> b.docs(d -> d.index(index).doc(jsonData)));

Stacktrace:

co.elastic.clients.util.MissingRequiredPropertyException: Missing required property 'MultiTermVectorsOperation.id'
	at co.elastic.clients.util.ApiTypeHelper.requireNonNull(ApiTypeHelper.java:76)
	at co.elastic.clients.elasticsearch.core.mtermvectors.MultiTermVectorsOperation.<init>(MultiTermVectorsOperation.java:99)
	at co.elastic.clients.elasticsearch.core.mtermvectors.MultiTermVectorsOperation.<init>(MultiTermVectorsOperation.java:57)

But if I add the requested id, my cluster will correctly respond:

co.elastic.clients.elasticsearch._types.ElasticsearchException: [es/mtermvectors] failed: [parse_exception] failed to parse term vectors request. either [id] or [doc] can be specified, but not both!
	at co.elastic.clients.transport.ElasticsearchTransportBase.getApiResponse(ElasticsearchTransportBase.java:345)
	at co.elastic.clients.transport.ElasticsearchTransportBase.performRequest(ElasticsearchTransportBase.java:147)

So if the MultiTermVectorsOperation validation could just let me create the request without an id, it would work.

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants