# Controlling date field in attachment type

**URL:** <https://discuss.elastic.co/t/controlling-date-field-in-attachment-type/12540>\
**Category:** Elasticsearch\
**Created:** [June 25, 2013, 10:00am UTC](https://discuss.elastic.co/t/controlling-date-field-in-attachment-type/12540 "2013-06-25T10:00:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Srivatsa\_Katta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/srivatsa_katta/32/2256_2.png) [@Srivatsa\_Katta](https://discuss.elastic.co/u/Srivatsa_Katta)\
**Post date:** [June 25, 2013, 10:00am UTC](https://discuss.elastic.co/t/controlling-date-field-in-attachment-type/12540/1 "2013-06-25T10:00:55Z")

</div>

Hi,

Am using attachment mapper plugin and having issues with the date formats  
for few html pages.

The exception am getting when I index a html file as an attachment is

org.elasticsearch.index.mapper.MapperParsingException: Failed to parse  
[content.date]  
at  
org.elasticsearch.index.mapper.core.AbstractFieldMapper.parse(AbstractFieldMapper.java:320)  
at  
org.elasticsearch.index.mapper.attachment.AttachmentMapper.parse(AttachmentMapper.java:327)  
at  
org.elasticsearch.index.mapper.object.ObjectMapper.serializeValue(ObjectMapper.java:587)  
at  
org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper.java:459)  
at  
org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:486)  
at  
org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:430)  
at  
org.elasticsearch.index.shard.service.InternalIndexShard.prepareCreate(InternalIndexShard.java:297)  
at  
org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:211)  
at  
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:532)  
at  
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:430)  
at  
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)  
at java.lang.Thread.run(Thread.java:722)  
Caused by: org.elasticsearch.index.mapper.MapperParsingException: failed to  
parse date field [Wed Jun 05 13:36:17 PDT 2013], tried both date format  
[dateOptionalTime], and timestamp number  
at  
org.elasticsearch.index.mapper.core.DateFieldMapper.parseStringValue(DateFieldMapper.java:432)  
at  
org.elasticsearch.index.mapper.core.DateFieldMapper.innerParseCreateField(DateFieldMapper.java:361)  
at  
org.elasticsearch.index.mapper.core.NumberFieldMapper.parseCreateField(NumberFieldMapper.java:182)  
at  
org.elasticsearch.index.mapper.core.AbstractFieldMapper.parse(AbstractFieldMapper.java:307)  
... 12 more  
Caused by: java.lang.IllegalArgumentException: Invalid format: "Wed Jun 05  
13:36:17 PDT 2013"  
at  
org.elasticsearch.common.joda.time.format.DateTimeFormatter.parseMillis(DateTimeFormatter.java:747)  
at  
org.elasticsearch.index.mapper.core.DateFieldMapper.parseStringValue(DateFieldMapper.java:426)  
... 15 more

The mapping looks like this (curl localhost:9200/examples/files/\_mapping)

{  
"files": {  
"properties": {  
"content": {  
"fields": {  
"author": {  
"type": "string"  
},  
"content": {  
"include\_in\_all": true,  
"store": "yes",  
"term\_vector": "with\_positions\_offsets",  
"type": "string"  
},  
"content\_type": {  
"type": "string"  
},  
"date": {  
_"format": "dateOptionalTime",_  
"type": "date"  
},  
"keywords": {  
"type": "string"  
},  
"name": {  
"type": "string"  
},  
"title": {  
"type": "string"  
}  
},  
"path": "full",  
"type": "attachment"  
}  
}  
}  
}

I tried setting date format explicitly and mapping after this change looks  
like this

{  
"files": {  
"properties": {  
"content": {  
"fields": {  
"author": {  
"type": "string"  
},  
"content": {  
"include\_in\_all": true,  
"store": "yes",  
"term\_vector": "with\_positions\_offsets",  
"type": "string"  
},  
"content\_type": {  
"type": "string"  
},  
"date": {

- 

```
                   "format": "EEE MMM dd HH:mm:ss z yyyy",*
                  "type": "date"
              },
              "keywords": {
                  "type": "string"
              },
              "name": {
                  "type": "string"
              },
              "title": {
                  "type": "string"
              }
          },
          "path": "full",
          "type": "attachment"
      }
  }

```

}  
}

Even then its throwing up the same above exception.

1. I checked if the format give is wrong, but doesn't seem like. Why is it  
not honouring the format given in mapping ?
2. Is there a way to change the type of the date field in attachment type  
to string (given that I dont have any querying needs on that field)

Appreciate your thoughts on handling this.

-katta

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 25, 2013, 4:08pm UTC](https://discuss.elastic.co/t/controlling-date-field-in-attachment-type/12540/2 "2013-06-25T16:08:13Z")

</div>

We get somehow the same question on the french mailing list with another field for which the explicit mapping seems to be overwrote by mapper attachment.  
I'll give a look into this in the next days.

Thanks!

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 25 juin 2013 à 12:00, Srivatsa Katta [vatsa.katta@gmail.com](mailto:vatsa.katta@gmail.com) a écrit :

> Hi,
> 
> Am using attachment mapper plugin and having issues with the date formats for few html pages.
> 
> The exception am getting when I index a html file as an attachment is
> 
> org.elasticsearch.index.mapper.MapperParsingException: Failed to parse [content.date]  
> at org.elasticsearch.index.mapper.core.AbstractFieldMapper.parse(AbstractFieldMapper.java:320)  
> at org.elasticsearch.index.mapper.attachment.AttachmentMapper.parse(AttachmentMapper.java:327)  
> at org.elasticsearch.index.mapper.object.ObjectMapper.serializeValue(ObjectMapper.java:587)  
> at org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper.java:459)  
> at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:486)  
> at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:430)  
> at org.elasticsearch.index.shard.service.InternalIndexShard.prepareCreate(InternalIndexShard.java:297)  
> at org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:211)  
> at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:532)  
> at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:430)  
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)  
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)  
> at java.lang.Thread.run(Thread.java:722)  
> Caused by: org.elasticsearch.index.mapper.MapperParsingException: failed to parse date field [Wed Jun 05 13:36:17 PDT 2013], tried both date format [dateOptionalTime], and timestamp number  
> at org.elasticsearch.index.mapper.core.DateFieldMapper.parseStringValue(DateFieldMapper.java:432)  
> at org.elasticsearch.index.mapper.core.DateFieldMapper.innerParseCreateField(DateFieldMapper.java:361)  
> at org.elasticsearch.index.mapper.core.NumberFieldMapper.parseCreateField(NumberFieldMapper.java:182)  
> at org.elasticsearch.index.mapper.core.AbstractFieldMapper.parse(AbstractFieldMapper.java:307)  
> ... 12 more  
> Caused by: java.lang.IllegalArgumentException: Invalid format: "Wed Jun 05 13:36:17 PDT 2013"  
> at org.elasticsearch.common.joda.time.format.DateTimeFormatter.parseMillis(DateTimeFormatter.java:747)  
> at org.elasticsearch.index.mapper.core.DateFieldMapper.parseStringValue(DateFieldMapper.java:426)  
> ... 15 more
> 
> The mapping looks like this (curl localhost:9200/examples/files/\_mapping)
> 
> {  
> "files": {  
> "properties": {  
> "content": {  
> "fields": {  
> "author": {  
> "type": "string"  
> },  
> "content": {  
> "include\_in\_all": true,  
> "store": "yes",  
> "term\_vector": "with\_positions\_offsets",  
> "type": "string"  
> },  
> "content\_type": {  
> "type": "string"  
> },  
> "date": {  
> "format": "dateOptionalTime",  
> "type": "date"  
> },  
> "keywords": {  
> "type": "string"  
> },  
> "name": {  
> "type": "string"  
> },  
> "title": {  
> "type": "string"  
> }  
> },  
> "path": "full",  
> "type": "attachment"  
> }  
> }  
> }  
> }
> 
> I tried setting date format explicitly and mapping after this change looks like this
> 
> {  
> "files": {  
> "properties": {  
> "content": {  
> "fields": {  
> "author": {  
> "type": "string"  
> },  
> "content": {  
> "include\_in\_all": true,  
> "store": "yes",  
> "term\_vector": "with\_positions\_offsets",  
> "type": "string"  
> },  
> "content\_type": {  
> "type": "string"  
> },  
> "date": {  
> "format": "EEE MMM dd HH:mm:ss z yyyy",  
> "type": "date"  
> },  
> "keywords": {  
> "type": "string"  
> },  
> "name": {  
> "type": "string"  
> },  
> "title": {  
> "type": "string"  
> }  
> },  
> "path": "full",  
> "type": "attachment"  
> }  
> }  
> }  
> }
> 
> Even then its throwing up the same above exception.
> 
> 1. I checked if the format give is wrong, but doesn't seem like. Why is it not honouring the format given in mapping ?
> 2. Is there a way to change the type of the date field in attachment type to string (given that I dont have any querying needs on that field)
> 
> Appreciate your thoughts on handling this.
> 
> -katta
> 
> --  
> 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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Srivatsa\_Katta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/srivatsa_katta/32/2256_2.png) [@Srivatsa\_Katta](https://discuss.elastic.co/u/Srivatsa_Katta)\
**Post date:** [June 26, 2013, 6:34am UTC](https://discuss.elastic.co/t/controlling-date-field-in-attachment-type/12540/3 "2013-06-26T06:34:37Z")

</div>

Thanks David,

That will really help.

-katta

On Tue, Jun 25, 2013 at 9:38 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> We get somehow the same question on the french mailing list with another  
> field for which the explicit mapping seems to be overwrote by mapper  
> attachment.  
> I'll give a look into this in the next days.
> 
> Thanks!
> 
> --  
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)  
> | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)
> 
> Le 25 juin 2013 à 12:00, Srivatsa Katta [vatsa.katta@gmail.com](mailto:vatsa.katta@gmail.com) a écrit :
> 
> Hi,
> 
> Am using attachment mapper plugin and having issues with the date formats  
> for few html pages.
> 
> The exception am getting when I index a html file as an attachment is
> 
> org.elasticsearch.index.mapper.MapperParsingException: Failed to parse  
> [content.date]  
> at  
> org.elasticsearch.index.mapper.core.AbstractFieldMapper.parse(AbstractFieldMapper.java:320)  
> at  
> org.elasticsearch.index.mapper.attachment.AttachmentMapper.parse(AttachmentMapper.java:327)  
> at  
> org.elasticsearch.index.mapper.object.ObjectMapper.serializeValue(ObjectMapper.java:587)  
> at  
> org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper.java:459)  
> at  
> org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:486)  
> at  
> org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:430)  
> at  
> org.elasticsearch.index.shard.service.InternalIndexShard.prepareCreate(InternalIndexShard.java:297)  
> at  
> org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:211)  
> at  
> org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:532)  
> at  
> org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:430)  
> at  
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)  
> at java.lang.Thread.run(Thread.java:722)  
> Caused by: org.elasticsearch.index.mapper.MapperParsingException: failed  
> to parse date field [Wed Jun 05 13:36:17 PDT 2013], tried both date format  
> [dateOptionalTime], and timestamp number  
> at  
> org.elasticsearch.index.mapper.core.DateFieldMapper.parseStringValue(DateFieldMapper.java:432)  
> at  
> org.elasticsearch.index.mapper.core.DateFieldMapper.innerParseCreateField(DateFieldMapper.java:361)  
> at  
> org.elasticsearch.index.mapper.core.NumberFieldMapper.parseCreateField(NumberFieldMapper.java:182)  
> at  
> org.elasticsearch.index.mapper.core.AbstractFieldMapper.parse(AbstractFieldMapper.java:307)  
> ... 12 more  
> Caused by: java.lang.IllegalArgumentException: Invalid format: "Wed Jun 05  
> 13:36:17 PDT 2013"  
> at  
> org.elasticsearch.common.joda.time.format.DateTimeFormatter.parseMillis(DateTimeFormatter.java:747)  
> at  
> org.elasticsearch.index.mapper.core.DateFieldMapper.parseStringValue(DateFieldMapper.java:426)  
> ... 15 more
> 
> The mapping looks like this (curl localhost:9200/examples/files/\_mapping)
> 
> {  
> "files": {  
> "properties": {  
> "content": {  
> "fields": {  
> "author": {  
> "type": "string"  
> },  
> "content": {  
> "include\_in\_all": true,  
> "store": "yes",  
> "term\_vector": "with\_positions\_offsets",  
> "type": "string"  
> },  
> "content\_type": {  
> "type": "string"  
> },  
> "date": {  
> _"format": "dateOptionalTime",_  
> "type": "date"  
> },  
> "keywords": {  
> "type": "string"  
> },  
> "name": {  
> "type": "string"  
> },  
> "title": {  
> "type": "string"  
> }  
> },  
> "path": "full",  
> "type": "attachment"  
> }  
> }  
> }  
> }
> 
> I tried setting date format explicitly and mapping after this change looks  
> like this
> 
> {  
> "files": {  
> "properties": {  
> "content": {  
> "fields": {  
> "author": {  
> "type": "string"  
> },  
> "content": {  
> "include\_in\_all": true,  
> "store": "yes",  
> "term\_vector": "with\_positions\_offsets",  
> "type": "string"  
> },  
> "content\_type": {  
> "type": "string"  
> },  
> "date": {
> 
> - 
> 
> ```
> "format": "EEE MMM dd HH:mm:ss z yyyy",*
> "type": "date"
> },
> "keywords": {
> "type": "string"
> },
> "name": {
> "type": "string"
> },
> "title": {
> "type": "string"
> }
> },
> "path": "full",
> "type": "attachment"
> }
> }
> 
> ```
> 
> }  
> }
> 
> Even then its throwing up the same above exception.
> 
> 1. I checked if the format give is wrong, but doesn't seem like. Why is it  
> not honouring the format given in mapping ?
> 2. Is there a way to change the type of the date field in attachment type  
> to string (given that I dont have any querying needs on that field)
> 
> Appreciate your thoughts on handling this.
> 
> -katta
> 
> --  
> 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](mailto:elasticsearch+unsubscribe@googlegroups.com).
> 
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:29am UTC](https://discuss.elastic.co/t/controlling-date-field-in-attachment-type/12540/4 "2017-07-06T02:29:28Z")

</div>


