Java update API doesn't support serialization of Collection


(Paul Bellora) #1

I tried to provide a HashSet as a parameter to an update script and
got this exception:

java.io.IOException: Can't write type [class java.util.HashSet]
at
org.elasticsearch.common.io.stream.StreamOutput.writeGenericValue(StreamOutput.java:390)
at
org.elasticsearch.common.io.stream.StreamOutput.writeGenericValue(StreamOutput.java:369)
at
org.elasticsearch.common.io.stream.StreamOutput.writeMap(StreamOutput.java:314)
at
org.elasticsearch.action.update.UpdateRequest.writeTo(UpdateRequest.java:604)
at
org.elasticsearch.transport.netty.NettyTransport.sendRequest(NettyTransport.java:545)
at
org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:188)
at
org.elasticsearch.action.support.single.instance.TransportInstanceSingleOperationAction$AsyncSingleAction.start(TransportInstanceSingleOperationAction.java:203)
at
org.elasticsearch.action.support.single.instance.TransportInstanceSingleOperationAction$AsyncSingleAction.start(TransportInstanceSingleOperationAction.java:128)
at
org.elasticsearch.action.support.single.instance.TransportInstanceSingleOperationAction.doExecute(TransportInstanceSingleOperationAction.java:71)
at
org.elasticsearch.action.update.TransportUpdateAction.innerExecute(TransportUpdateAction.java:158)
at
org.elasticsearch.action.update.TransportUpdateAction.doExecute(TransportUpdateAction.java:153)
at
org.elasticsearch.action.update.TransportUpdateAction.doExecute(TransportUpdateAction.java:63)
at
org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:61)
at
org.elasticsearch.client.node.NodeClient.execute(NodeClient.java:92)
at
org.elasticsearch.client.support.AbstractClient.update(AbstractClient.java:109)
at
org.elasticsearch.action.update.UpdateRequestBuilder.doExecute(UpdateRequestBuilder.java:332)
at
org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:85)
at
org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:59)

Looking at the source of StreamOutput.writeGenericValuehttps://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/common/io/stream/StreamOutput.java#L339,
it seems only List, not Collection, is supported for marshalling. I
resolved my issue just by copying the set to a list, but I'm wondering why
this limitation exists.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #2