- Notifications
You must be signed in to change notification settings - Fork 275
Closed
Closed
Copy link
Labels
Area: SpecificationRelated to the API spec used to generate client codeRelated to the API spec used to generate client codeCategory: BugSomething isn't workingSomething isn't working
Description
The PutScript API supports scripts in string format and mustache search templates in json object format. These options are detailed in the API Docs.
The existing generated code for StoredScript only accepts string data for the script source. This makes it impossible for the client to create or update search templates written in mustache.
PutScriptResponse response = elasticsearchClient.putScript(req -> req .id(entry.getKey()) .script(s -> s .source(...)) // Only accepts string data );
If trying to read in a valid script request body there are parsing errors:
{ "script": { "lang": "mustache", "source": { "query": { "match": { "all": { "query": "{{query_string}}" } } } } } }
Reader scriptJson = ... PutScriptResponse response = elasticsearchClient.putScript(req -> req .id(entry.getKey()) .withJson(scriptJson) );
Exception in thread "main" co.elastic.clients.json.JsonpMappingException: Error deserializing co.elastic.clients.elasticsearch._types.StoredScript: co.elastic.clients.json.UnexpectedJsonEventException: Unexpected JSON event 'START_OBJECT' instead of '[KEY_NAME, VALUE_STRING, VALUE_NUMBER, VALUE_TRUE, VALUE_FALSE]' (JSON path: script.source) (line no=4, column no=16, offset=55) at co.elastic.clients.json.JsonpMappingException.from0(JsonpMappingException.java:134) at co.elastic.clients.json.JsonpMappingException.from(JsonpMappingException.java:121) at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:218) at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:148) at co.elastic.clients.json.JsonpDeserializer.deserialize(JsonpDeserializer.java:77) at co.elastic.clients.json.ObjectBuilderDeserializer.deserialize(ObjectBuilderDeserializer.java:79) at co.elastic.clients.json.DelegatingDeserializer$SameType.deserialize(DelegatingDeserializer.java:43) at co.elastic.clients.json.ObjectDeserializer$FieldObjectDeserializer.deserialize(ObjectDeserializer.java:78) at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:192) at co.elastic.clients.util.WithJsonObjectBuilderBase.withJson(WithJsonObjectBuilderBase.java:54) at co.elastic.clients.json.WithJson.withJson(WithJson.java:57) at co.elastic.clients.elasticsearch.ElasticsearchClient.putScript(ElasticsearchClient.java:1641) Caused by: co.elastic.clients.json.UnexpectedJsonEventException: Unexpected JSON event 'START_OBJECT' instead of '[KEY_NAME, VALUE_STRING, VALUE_NUMBER, VALUE_TRUE, VALUE_FALSE]' at co.elastic.clients.json.JsonpUtils.ensureAccepts(JsonpUtils.java:117) at co.elastic.clients.json.JsonpDeserializer.deserialize(JsonpDeserializer.java:76) at co.elastic.clients.json.ObjectDeserializer$FieldObjectDeserializer.deserialize(ObjectDeserializer.java:78) at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:192) ... 13 more
Metadata
Metadata
Assignees
Labels
Area: SpecificationRelated to the API spec used to generate client codeRelated to the API spec used to generate client codeCategory: BugSomething isn't workingSomething isn't working