Script plugin parameters throw IOException: can not write type


(Hector R ) #1

Hi all,

we are upgrading elastic search from 2.3.3 to 5.4.0 and facing a problem. We have a plugin with a native script registered. The script field is added like this to the search request:

ImmutableMap<String, Object> params = ImmutableMap.<String, Object>of(
                "command", command,
                "session", new XContentSession(EvaluatorSessionElement.buildSession(binding, getSelections(), elementConstraintMap, false))
        );
                
requestBuilder.addScriptField("result", new Script(ScriptType.INLINE, "native", "tql-evaluator", params));

XContentSession is a class that implements ToXContent.

In 2.3.3, although the second parameter was a XContentSession, it was passed to the script as a Map and there we converted it to XContentSession. Upgrading to 5.4.0, it seems the parameter is passed as a XContentSession, which seems good and better, but then when executing the search request we got an exception like:

! java.io.IOException: can not write type [class com.artisol.dolabra.es.tql.plugin.adapters.XContentSession]
! at org.elasticsearch.common.io.stream.StreamOutput.writeGenericValue(StreamOutput.java:655)
! at org.elasticsearch.common.io.stream.StreamOutput.lambda$static$11(StreamOutput.java:570)
! at org.elasticsearch.common.io.stream.StreamOutput.writeGenericValue(StreamOutput.java:653)
! at org.elasticsearch.common.io.stream.StreamOutput.writeMap(StreamOutput.java:443)
! at org.elasticsearch.script.Script.writeTo(Script.java:566)
! at org.elasticsearch.search.builder.SearchSourceBuilder$ScriptField.writeTo(SearchSourceBuilder.java:1346)
! at org.elasticsearch.common.io.stream.StreamOutput.writeList(StreamOutput.java:915)
! at org.elasticsearch.search.builder.SearchSourceBuilder.writeTo(SearchSourceBuilder.java:249)
! at org.elasticsearch.common.io.stream.StreamOutput.writeOptionalWriteable(StreamOutput.java:732)
! at org.elasticsearch.action.search.SearchRequest.writeTo(SearchRequest.java:361)
! at org.elasticsearch.transport.TcpTransport.buildMessage(TcpTransport.java:1210)
! at org.elasticsearch.transport.TcpTransport.sendRequestToChannel(TcpTransport.java:1062)
! at org.elasticsearch.transport.TcpTransport.access$1100(TcpTransport.java:115)
! at org.elasticsearch.transport.TcpTransport$NodeChannels.sendRequest(TcpTransport.java:438)
! at org.elasticsearch.transport.TransportService.sendRequestInternal(TransportService.java:569)
! at org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:502)
! at org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:490)
! at org.elasticsearch.action.TransportActionNodeProxy.execute(TransportActionNodeProxy.java:51)
! at org.elasticsearch.client.transport.TransportProxyClient.lambda$execute$0(TransportProxyClient.java:59)
! at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:251)
! at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:59)
! at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:366)
! at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:408)
! at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:80)
! at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:54)
! ... 14 common frames omitted

Any ideas of what we are missing? Is this change in behaviour between versions intended? Do we need to convert the param to a Map (and all submaps) or elastic search offers something? Parameters have to be objects so should be supported I guess.

Thanks!


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.