Mapper Attachments Plugin and SMILE

Hello

I've got a problem working with Mapper Attachments Plugin.

This code

val json = XContentFactory.jsonBuilder().startObject()
    .field("file").startObject()
      .field("content").value(Base64.encodeBytes(bytes))
    .endObject()
  .endObject()

client.prepareIndex(indexName, typeName)
  .setSource(json).execute().actionGet()

works perfectly well, but when I change jsonBuilder to smileBuilder, ES
throws

org.elasticsearch.index.mapper.MapperParsingException: failed to parse
at
org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:540)
at
org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:462)
at
org.elasticsearch.index.shard.service.InternalIndexShard.prepareCreate(InternalIndexShard.java:371)
at
org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:215)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:556)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:426)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.elasticsearch.common.jackson.core.JsonParseException:
Current token (VALUE_STRING) not VALUE_EMBEDDED_OBJECT, can not access as
binary
at [Source: [B@3cb66faa; line: -1, column: 98325]
at
org.elasticsearch.common.jackson.core.JsonParser._constructError(JsonParser.java:1524)
at
org.elasticsearch.common.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:557)
at
org.elasticsearch.common.jackson.dataformat.smile.SmileParser.getBinaryValue(SmileParser.java:1212)
at
org.elasticsearch.common.jackson.core.JsonParser.getBinaryValue(JsonParser.java:1131)
at
org.elasticsearch.common.xcontent.json.JsonXContentParser.binaryValue(JsonXContentParser.java:183)
at
org.elasticsearch.index.mapper.attachment.AttachmentMapper.parse(AttachmentMapper.java:321)
at
org.elasticsearch.index.mapper.object.ObjectMapper.serializeObject(ObjectMapper.java:517)
at
org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper.java:459)
at
org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:515)
... 8 more

and when I try not to encode the file

val json = XContentFactory.smileBuilder().startObject()
    .field("file").value(bytes)
  .endObject()

or

val json = XContentFactory.smileBuilder().startObject()
    .field("file").startObject()
      .field("content").value(bytes)
    .endObject()
  .endObject()

ES throws

org.elasticsearch.index.mapper.MapperParsingException: No content is
provided.
at
org.elasticsearch.index.mapper.attachment.AttachmentMapper.parse(AttachmentMapper.java:337)
at
org.elasticsearch.index.mapper.object.ObjectMapper.serializeValue(ObjectMapper.java:616)
at
org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper.java:469)
at
org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:515)
at
org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:462)
at
org.elasticsearch.index.shard.service.InternalIndexShard.prepareCreate(InternalIndexShard.java:371)
at
org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:215)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:556)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:426)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)

I am using SMILE so I am curious if there is some workaround or am I doing
something wrong?

Thanks in advance

Paweł Młynarczyk

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/59a46c68-8703-4254-9869-1ac6e1bac883%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.