Some of my documents have attachments, some don't. Right now the ones that don't do not get indexed at all.
My mapping is:
@mapping=
{:priref=>{:type=>"integer", :index=>"not_analyzed"},
:title=>{:type=>"string"},
:publisher=>{:type=>"string"},
:keywords=>{:type=>"string"},
:abstract=>{:type=>"string"},
:digital_reference=>{:index=>"not_analyzed", :type=>"string"},
:language_code=>{:index=>"not_analyzed", :type=>"string"},
:year=>{:type=>"string"},
:material_type=>
{:analyzer=>"snowball", :index=>"not_analyzed", :type=>"string"},
:theme=>{:analyzer=>"snowball", :index=>"not_analyzed", :type=>"string"},
:created_at=>{:type=>"date", :index=>"not_analyzed"},
:updated_at=>{:type=>"date", :index=>"not_analyzed"},
:authors=>
{:type=>"object",
:properties=>{:name=>{:analyzer=>"snowball", :type=>"string"}}},
:attachment=>{:type=>"attachment", :store=>true}},
@options={:_source=>{:excludes=>["attachment"]}},
@type="document">
A few of my documents do not have an attachment. When indexing i get the following error:
MapperParsingException: No content is provided
Full error:
org.elasticsearch.index.mapper.MapperParsingException: No content is provided.
at org.elasticsearch.index.mapper.attachment.AttachmentMapper.parse(AttachmentMapper.java:371)
at org.elasticsearch.index.mapper.object.ObjectMapper.serializeNullValue(ObjectMapper.java:505)
at org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper.java:465)
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.prepareIndex(InternalIndexShard.java:384)
at org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:203)
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:745)
How can i make sure the attachment is optional?
I'm using the Mapper attachments plugin and Elasticsearch 1.1.2